如何找到需要 Microsoft Graph "Read directory data" 权限的 Azure AD 应用程序的管理员许可 URL?

How can I find the Admin Consent URL for an Azure AD App that requires Microsoft Graph "Read directory data" permission?

我正在看下面的例子:

https://azure.microsoft.com/resources/samples/active-directory-dotnet-webapp-groupclaims/

对于 运行 示例,我需要 Directory.Read.All Microsoft Graph 的权限:

Configure Permissions for your application. To that extent, in the Settings menu, choose the 'Required permissions' section and then, click on Add, then Select an API, and type Microsoft Graph in the textbox. Then, click on Select Permissions and select Directory.Read.All.

Directory.Read.All 需要 Azure AD 管理员同意。
我的 Azure AD 应用程序没有 Web 用户界面。

我有哪些选择可以让我们的 Azure AD 管理员在不占用太多时间的情况下提供同意?

我们的 Azure AD 管理员是一个繁忙且昂贵的资源。预订他的时间需要努力,我希望我可以在让他参与之前排练同意过程。

您有两个选择:使用 Azure 门户,或建立许可 URL。

  1. 使用 Azure 门户

    如果应用程序在您需要权限的同一个 Azure AD 租户中注册,那么您可以要求管理员在 Azure 门户中进行应用程序注册,然后导航至 设置 > 所需权限并单击授予权限:

    在新的(截至 2018 年 11 月 14 日)应用程序注册(预览版)体验中,这在 API 下 权限 > 授予管理员同意...:

    如果你自己去这个画面,你可以复制URL分享给管理员,帮助他快速找到合适的blade

  2. 建立同意URL

    即使您的应用不提供网络体验,从技术上讲,您仍然可以构建 URL 来请求管理员同意,尽管体验不是很好。有关如何构建管理员许可 URL 的详细信息,请参阅文档:https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent#request-the-permissions-from-a-directory-admin

    最简单的形式是:

    https://login.microsoftonline.com/common/adminconsent?client_id={client-id}
    

    使用这种方法,一旦管理员同意,他将被重定向到您的应用注册中配置的授权回复之一 URL(或特定的 URL,如果您使用redirect_uri 参数)。如果这是不存在的 URL,浏览器将显示错误(例如 404)。如果没有为您的应用程序注册配置回复 URL,Azure AD 将显示错误(例如 "no reply URLs configured")。您应该警告管理员这可能会发生,但由于这些错误将在 同意后显示,因此可以忽略它们。