我在https://apps.dev.microsoft.com创建了一个应用程序
具有以下应用程序权限:
Calendars.Read (Admin Only)
Calendars.ReadWrite (Admin Only)
User.Read.All (Admin Only)
Admin Consent
然后通过此URL成功授予管理员同意
https://login.microsoftonline.com/strixtechnology.onmicrosoft.com/adminconsent?client_id=bbb35336-faee-4c10-84b4-34136634db41&state=1234&redirect_uri=https%3A%2F%2Fdashmeetings.com%2Fmicrosoft%2Foauth
Get access token
然后从中获取访问令牌
POST https://login.microsoftonline.com/common/oauth2/v2.0/token
带 Headers
Content-Type=application/x-www-form-urlencoded
和键值对的身体
grant_type=client_credentials
client_id=bbb35336-faee-4c10-84b4-34136634db41
client_secret=xxx
scope=https://graph.microsoft.com/.default
这将返回一个访问令牌 .
Subscribe to notifications
使用该访问令牌,然后我尝试订阅某个资源邮箱上的事件:
POST https://graph.microsoft.com/beta/subscriptions
带 Headers
Content-Type=application/json
Authorization=Bearer <access_token_here>
与身体
{
"changeType": "created,updated,deleted",
"notificationUrl": "https://dashmeetings.com/microsoft/notify",
"resource": "users/mahogany@strixtechnology.com/events",
"expirationDateTime":"2017-12-01T11:00:00.0000000Z",
"clientState":"1234"
}
这将返回 401 Unauthorized
{
"error": {
"code": "ExtensionError",
"message": "Operation: Create; Exception: [Status Code: Unauthorized; Reason: Unauthorized]",
"innerError": {
"request-id": "98ce5e5e-1ce4-4417-8c35-456a3cc0e696",
"date": "2017-11-30T10:59:28"
}
}
}
这个问题似乎与“Resource not found for the segment” using Graph subscription beta相似,但我没有任何运气也遵循相同的步骤
1 回答
管理员同意URL必须是
和访问令牌地址:
https://login.microsoftonline.com/<tenant_id>/oauth2/v2.0/token