我已使用 Azure Active Directory PowerShell V2 编写了创建 Azure Active Directory 应用程序的脚本。我正在尝试在我的单页应用程序 (SPA) 中使用委派权限,使用隐式流程来调用定义了应用程序角色的 API。
我需要使用什么 PowerShell 命令来复制 Azure 门户中“应用程序设置”下的“授予权限”按钮:
根据Docs :
Granting explicit consent using the Grant Permissions button is currently required for single page applications (SPA) using ADAL.js, as the access token is requested without a consent prompt, which will fail if consent is not already granted.
另外,如何判断是否已授予权限?按钮总是可点击的?如果你问我,我的用户体验很糟糕。
最佳答案
此按钮实际上是在进行管理员同意。这将同意租户中的所有用户。对于您的情况,如果您想避免Azure Portal,则可以在 SPA 中而不是在 PowerShell 中强制同意。 。
为此,您的 SPA 应在身份验证请求上附加 &prompt=consent
或 &prompt=admin_consent
。前者应该在每次新用户第一次登录时应用,而后者您可以执行一次(使用管理员帐户登录),并且它会同意所有用户。
关于powershell - 如何使用 Azure Active Directory PowerShell V2 'Grant Permissions',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43143075/