【发布时间】:2021-10-01 04:44:35
【问题描述】:
我已设置 Office 365 E3 试用帐户。我在 AAD 中注册了两个应用程序。
第一个使用“授权代码流”并按预期工作(可以访问登录的用户日历)。
第二个应用程序使用“客户端凭据流”并且不起作用。
-
登录浏览器(边缘)
GET /OAuthTest3 HTTP/1.1 HTTP/1.1 302 Found Location: https://login.microsoftonline.com/<tenant>/adminconsent?client_id=<app_id>&redirect_uri=http://localhost:1234/OAuthTest3 GET /OAuthTest3?admin_consent=True&tenant=<tenant> HTTP/1.1 HTTP/1.1 200 OK -
连接到https://login.microsoftonline.com/
POST /<tenant>/oauth2/token HTTP/1.1 Host: login.microsoftonline.com client_id=<app_id>& client_secret=<client_secret>& grant_type=client_credentials& redirect_uri=http://localhost:1234/OAuthTest3& resource=https://graph.microsoft.com/& scope=https://graph.microsoft.com/calendars.readwrite HTTP/1.1 200 OK { "token_type": "Bearer", "expires_in": "3600", "ext_expires_in": "0", "expires_on": "1504333342", "not_before": "1504329442", "resource": "https://graph.microsoft.com/", "access_token": <token> } -
连接到https://graph.microsoft.com/
GET /v1.0/users/<user>/calendars HTTP/1.1 Host: graph.microsoft.com Authorization: Bearer <token> HTTP/1.1 403 Forbidden { "error": { "code": "ErrorAccessDenied", "message": "Access is denied. Check credentials and try again.", "innerError": { "request-id": "e7228de4-2b27-4779-abef-ccab0d88970a", "date": "2017-09-02T05:22:27" } } }
【问题讨论】:
-
你好,埃米尔。我想您使用的是 V2 端点,您使用的是哪个库?
-
您好 Jean-Marc,我使用端点 login.microsoftonline.com/<tenant>/adminconsent 和 login.microsoftonline.com/<tenant>/oauth2/token 进行授权。 graph.microsoft.com/v1.0/users/<user-id> 用于图形 api。我正在实现自己的库。
标签: azure-active-directory microsoft-graph-api