Oauth into Office 365 Unified (preview) - server e

2019-08-31 13:49发布

问题:

I'm trying to oauth into Office 365's Unified API to read Calendar information and believe I have everything configured correctly. However, when after the user logs in and provides consent, they are redirected to the reply url with the following error in the params:

"Server error - non retryable error has occurred".

I've setup my AD app to have Office 365 Unified (Preview) Delegated Permission - Read users calendar, and am using the endpoints and client IDs specified. It seems like it can get to the consent screen, but after that, breaks. What I find is if I remove the resource param, I'm able to get a code. However when I try to post for a token, I get a response that the https://graph.microsoft.com/ is not available for my app (though it is through AD). Is there another place/setting I need to make graph.microsoft.com available for my AD app? My code snippet:

var oauthOptions = {
    client_id: '<My client ID value>',
    redirect_uri: '<My reply url>',
    response_type: 'code',
    prompt: 'admin_consent',
    resource: encodeURIComponent('https://graph.microsoft.com/')
};

var oauthUrl = 'https://login.microsoftonline.com/b678e2cc-6ccc-44a6-9802-176bc170d680/oauth2/authorize?api-version=1.0'
                        + '&response_type=' + oauthOptions.response_type
                        + '&redirect_uri=' + oauthOptions.redirect_uri
                        + '&client_id=' + oauthOptions.client_id
                        + '&prompt=' + oauthOptions.prompt
                        + '&resource=' + oauthOptions.resource;

window.location.href = oauthUrl;

Thank you!