在Office 365 API中使用多个范围 [英] Use multiple scopes with the Office 365 API

查看:94
本文介绍了在Office 365 API中使用多个范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用两个范围https://outlook.office.com/Mail.Readhttps://outlook.office.com/calendars.read来读取经过身份验证的用户的电子邮件和日历.我遵循了官方.Net(WPF)教程对用户进行身份验证并获得令牌.只要我的范围只是以上范围之一,它就可以很好地工作.两者同时使用时,我在尝试获取令牌时不会找回令牌.

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.

基本上就是我要做的:

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)); 

我在做什么错了?

推荐答案

尝试将Mail.Read范围更改为所有小写:

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" };

它看起来像ADAL库中的错误.我在GitHub上提交了问题.

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

这篇关于在Office 365 API中使用多个范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆