【问题标题】:Use multiple scopes with the Office 365 API通过 Office 365 API 使用多个范围
【发布时间】:2015-12-09 02:13:04
【问题描述】:

我想使用https://outlook.office.com/Mail.Readhttps://outlook.office.com/calendars.read 这两个范围来读取经过身份验证的用户的电子邮件和日历。我按照official .Net (WPF) tutorial 对用户进行身份验证并获取令牌。只要我的范围只是上述范围之一,它就可以很好地工作。一旦我同时使用两者,当我尝试获取它时,我就不会取回它。

这基本上就是我所做的:

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

我做错了什么?

【问题讨论】:

    标签: office365 office365api outlook-restapi microsoft-graph-api office365-restapi


    【解决方案1】:

    尝试将您的 Mail.Read 范围更改为全部小写:

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

    这看起来像是 ADAL 库中的一个错误。我提交了issue on GitHub

    【讨论】:

    • 非常感谢您的评论。这解决了我的问题。我也用小写字母尝试过一次,但很可能当时我还有其他事情发生,这导致了另一个问题......顺便说一下,在 Outlook Mail REST API 参考中,所有范围都是用大写字母编写的(并且使用 http而不是 https)...
    猜你喜欢
    • 1970-01-01
    • 2015-11-28
    • 1970-01-01
    • 2023-03-17
    • 1970-01-01
    • 2020-08-07
    • 1970-01-01
    • 1970-01-01
    • 2014-08-22
    相关资源
    最近更新 更多