gpt4 book ai didi

通过 PowerShell 获得 Azure AD 管理员同意?

转载 作者:行者123 更新时间:2023-12-02 07:28:21 25 4
gpt4 key购买 nike

如今,作为 Azure Active Directory 应用程序管理员授予 OAuth 同意的唯一方法似乎是通过 Azure 门户。有什么方法可以通过 PowerShell 以编程方式执行此操作吗?如果没有,将来是否有计划添加此支持?

最佳答案

您似乎想要为 Azure 广告应用授予管理员同意

向应用程序授予管理员同意很容易,我们只需添加附加参数 prompt 参数,其值为 admin_consent。例如,下面是一个请求,请给予管理员同意:

https://login.microsoftonline.com/{tenant}/oauth2/authorize?
client_id=6731de76-14a6-49ae-97bc-6eba6914391e
&response_type=code
&redirect_uri=http%3A%2F%2Flocalhost%2Fmyapp%2F
&response_mode=query
&resource=https%3A%2F%2Fservice.contoso.com%2F
&state=12345
&prompt=admin_consent

您只需访问此网址即可向应用程序管理员授予许可 (6731de76-14a6-49ae-97bc-6eba6914391e)。而如果想通过PowerShell来实现,我们只需要通过PowerShell导航这个URL即可。例如,我们可以使用 Start-Process command-let,如下所示:

Start-Process -FilePath  "https://login.microsoftonline.com/{tenant}/oauth2/authorize?client_id=6731de76-14a6-49ae-97bc-6eba6914391e&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%2Fmyapp%2F&response_mode=query&resource=https%3A%2F%2Fservice.contoso.com%2F&state=12345&prompt=admin_consent"

更详细的OAuth协议(protocol)中的参数,可以引用下面的链接:

Authorize access to web applications using OAuth 2.0 and Azure Active Directory

授予 Azure AD V2.0 端点的管理员同意是不同的,您可以引用下面的链接了解授予 Azure AD V2.0 端点的管理员同意。

Using the admin consent endpoint

关于通过 PowerShell 获得 Azure AD 管理员同意?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46076784/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com