Use multiple scopes with the Office 365 API

耗尽温柔 提交于 2019-12-08 06:11:28

问题


I want to use the two scopes https://outlook.office.com/Mail.Read and https://outlook.office.com/calendars.read to read an authenticated users' email and calendar. I followed the official .Net (WPF) tutorial to authenticate the user and obtain a token. It works well as long as my scope is only one of the ones above. As soon as I use both, I don't get back a token when I try to obtain it.

That's basically what I do:

private static string[] scopes = { "https://outlook.office.com/Mail.Read", "https://outlook.office.com/calendars.read" };

// sign-in/authenticate logic (with PromptBehavior.Always/Never) from tutorial

// here, the result doesn't contain a token:
result = await authContext.AcquireTokenAsync(scopes, null, clientId, redirectUri, new PlatformParameters(PromptBehavior.Always, null)); 

What am I doing wrong?


回答1:


Try changing your Mail.Read scope to all lower-case:

private static string[] scopes = { "https://outlook.office.com/mail.read", "https://outlook.office.com/calendars.read" };

It looks like a bug in the ADAL library. I filed an issue on GitHub.



来源:https://stackoverflow.com/questions/34169639/use-multiple-scopes-with-the-office-365-api

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