Outlook notification subscription using Azure Webhook Domain Not Found

假装没事ソ 提交于 2020-01-15 10:23:05

问题


I am working on Creating a push notification for inbox messages to be sent to my azure webhook.

I have been following the documentation as a reference. Till now I have been able to create and register my app using the Azure app registration. I got the client_id and client_secret accordingly.

Shared below are the postman requests I made to first get the access code and then access_token and refresh_token from the Oauth authorization endpoints -

Getting the access code -

Endpoint - https://login.microsoftonline.com/{tenant}/oauth2/authorize

Authorization Type – Oauth 2.0

Headers – 
    Content Type:   application/x-www-form-urlencoded

Body – 
    response_type:  code
    client_id:      myClientId
    redirect_uri:   https://app.getpostman.com/oauth2/callback
    response_mode:  query
    scope:          https://outlook.office.com/mail.read

Getting the access_token -

Endpoint – 
https://login.microsoftonline.com/{tenant}/oauth2/token

Authorization Type – Oauth 2.0

Headers – 
    Content Type:   application/x-www-form-urlencoded

Body – 
    code:           **********access_code***************
    client_id:      myClientId
    scope:          https://outlook.office.com/mail.read
    grant_type:     authorization_code
    client_secret:  *********client_secret*********
    redirect_uri:   https://app.getpostman.com/oauth2/callback  
    resource:       myClientId

Now, as mentioned in the documentation, I am posting the following request for creating the subscription (using Fiddler) -

Endpoint – 
https://outlook.office.com/api/v2.0/me/subscriptions

Headers – 
    Authorization:      Bearer access_token_got_in_the_response_above
    Content Type:       application/json

Body – 
    @odata.type:        #Microsoft.OutlookServices.PushSubscription
    Resource:           https://outlook.office.com/api/v2.0/me/mailfolders('inbox')/messages
    NotificationURL:    https://myAzureFunctionApp.azurewebsites.net/api/HttpNotificationHandler
    ChangeType:         authorization_code

The problem is that the response I am getting is a 404 Not Found. More specifically, X-CasErrorCode: DomainNotFound. I have double checked to make sure there are no typos in any specification.

To give some more Info, I had previously tried this and was successful in creating the subscription for my personal hotmail account. The user I am stuck with has been added to the Azure Active Directory as a guest user under the same tenant my app has been registered.

UPDATE

Here are some more questions that might be useful -

  • The email address is say email1@contoso.com, and the tenant is ABCcontoso.onmicrosoft.com. Will it make any difference?

  • The user is not added to the user group using this application in the Azure Active Directory app registration section, the only user shown is the admin who had registered the app. Is this required?

  • The app was registered on the Microsoft App Registration Portal. But it is reflected in the Azure Active Directory under the tenant. So, is hitting the OAuth2 v1.0 endpoint correct?

  • What should be the endpoint for creating a notification subscription for a work/organization account having office 365 subscription? The current endpoint https://outlook.office.com/api/v2.0/me/subscriptions uses v2.0, but the token provided is by v1.0 endpoint (if I understand it correctly).

Any help is appreciated.

来源:https://stackoverflow.com/questions/48074857/outlook-notification-subscription-using-azure-webhook-domain-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!