简体   繁体   中英

Office 365 Authentication with Microsoft Graph

I previously used the following code for authentication on my application web server using a token obtained from Office.context.mailbox.getCallbackTokenAsync in my 365 client add-in:

ExchangeService service = new ExchangeService();
service.Credentials = new OAuthCredentials(token);
service.Url = new Uri(ewsUrl);

I am now trying to convert my EWS server code to Microsoft Graph, but I'm having trouble getting access to those APIs using that 365 token. I've tried something like this but to no avail:

var graphServiceClient = new GraphServiceClient(
                new DelegateAuthenticationProvider((requestMessage) =>
                {
                    requestMessage
                        .Headers
                        .Authorization = new AuthenticationHeaderValue("bearer", token);

                    return System.Threading.Tasks.Task.CompletedTask;
                }));

My Permissions in Azure should be okay as I've already been able to obtain various items and save into the system. Thanks for any help!

Graph 和 EWS 在其代币中具有不同的受众,您不能将两者混用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM