powershell - 如何使用 Azure Active Directory PowerShell V2 'Grant Permissions'

标签 powershell azure azure-active-directory azure-ad-powershell-v2

我已使用 Azure Active Directory PowerShell V2 编写了创建 Azure Active Directory 应用程序的脚本。我正在尝试在我的单页应用程序 (SPA) 中使用委派权限,使用隐式流程来调用定义了应用程序角色的 API。

我需要使用什么 PowerShell 命令来复制 Azure 门户中“应用程序设置”下的“授予权限”按钮:

Grant Permissions Button ScreenShot from the Azure Portal

根据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。前者应该在每次新用户第一次登录时应用,而后者您可以执行一次(使用管理员帐户登录),并且它会同意所有用户。

结账 understanding Admin and User Consent

关于powershell - 如何使用 Azure Active Directory PowerShell V2 'Grant Permissions',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43143075/

相关文章:

sql - json Web 服务输出到 azure sql with/credentials

azure-active-directory - 能否使用 Azure AD 作为身份提供商从 Azure AD B2C 登录获取 MSGraph 访问 token ?

powershell - 使用 PowerShell 创建硬链接(hard link)和软链接(soft link)

powershell - 动态创建 DSC 配置

sql - Azure SQL 数据库行号无法正常工作

c# - MSAL 与 Microsoft.Owin.Security.OpenIdConnect 有何关系?

azure - Azure 基于角色的访问控制 (RBAC) 中的角色和范围有什么区别?

powershell - StartsWith 在开关中

powershell - 如何使用 AAD+MultiFactorAuth 调用 sqlcmd(或 sqlcmd.exe)

c# - 如何通过azure函数应用程序从azure表存储中获取所有记录