访问图形的多租户应用程序问题 api
Multitenant app issue accessing graph api
我有一个带有 masal 和 Web 的多租户应用程序 js 客户端 Api 一切正常。用户可以登录并使用 Api.
我正在尝试使用 Graph Api 读取用户所属的广告组。
它适用于已注册应用程序的同一租户的用户,但如果我使用来自不同租户的用户,我有 403(权限不足,无法完成操作。)错误,试图访问 /users/{userId}/ memberOf 端点。
在为客户端和服务器在 azure 上注册应用程序后,我在 Api 权限部分(应用程序权限)中设置了适当的权限,我认为是这种情况,但它一定是我遗漏了其他东西。
知道我错过了什么吗?
请参考以下文章:
Understand user and admin consent
For a multi-tenant application, the initial registration for the application lives in the Azure AD tenant used by the developer. When a user from a different tenant signs in to the application for the first time, Azure AD asks them to consent to the permissions requested by the application. If they consent, then a representation of the application called a service principal is created in the user’s tenant, and sign-in can continue. A delegation is also created in the directory that records the user’s consent to the application.
您的应用程序使用需要管理员同意的权限(/users/{userId}/memberOf
),如果普通用户尝试登录请求需要管理员同意的委派权限的应用程序,您的应用程序会收到错误消息。
在 Azure AD V2.0 中,您可以将用户重定向到 Microsoft 身份平台管理员同意端点:
// Line breaks are for legibility only.
GET https://login.microsoftonline.com/{tenant}/v2.0/adminconsent?
client_id=6731de76-14a6-49ae-97bc-6eba6914391e
&state=12345
&redirect_uri=http://localhost/myapp/permissions
&scope=
https://graph.microsoft.com/calendars.read
https://graph.microsoft.com/mail.send
我有一个带有 masal 和 Web 的多租户应用程序 js 客户端 Api 一切正常。用户可以登录并使用 Api.
我正在尝试使用 Graph Api 读取用户所属的广告组。 它适用于已注册应用程序的同一租户的用户,但如果我使用来自不同租户的用户,我有 403(权限不足,无法完成操作。)错误,试图访问 /users/{userId}/ memberOf 端点。 在为客户端和服务器在 azure 上注册应用程序后,我在 Api 权限部分(应用程序权限)中设置了适当的权限,我认为是这种情况,但它一定是我遗漏了其他东西。 知道我错过了什么吗?
请参考以下文章:
Understand user and admin consent
For a multi-tenant application, the initial registration for the application lives in the Azure AD tenant used by the developer. When a user from a different tenant signs in to the application for the first time, Azure AD asks them to consent to the permissions requested by the application. If they consent, then a representation of the application called a service principal is created in the user’s tenant, and sign-in can continue. A delegation is also created in the directory that records the user’s consent to the application.
您的应用程序使用需要管理员同意的权限(/users/{userId}/memberOf
),如果普通用户尝试登录请求需要管理员同意的委派权限的应用程序,您的应用程序会收到错误消息。
在 Azure AD V2.0 中,您可以将用户重定向到 Microsoft 身份平台管理员同意端点:
// Line breaks are for legibility only.
GET https://login.microsoftonline.com/{tenant}/v2.0/adminconsent?
client_id=6731de76-14a6-49ae-97bc-6eba6914391e
&state=12345
&redirect_uri=http://localhost/myapp/permissions
&scope=
https://graph.microsoft.com/calendars.read
https://graph.microsoft.com/mail.send