【问题标题】:Office365 API: OAuth2 AccessTokens for app-only require that theOffice 365 API:仅适用于应用程序的 OAuth2 访问令牌要求
【发布时间】:2016-12-16 12:05:15
【问题描述】:

我正在使用此 URL 创建 Outlook 推送通知的订阅请求:

https://outlook.office365.com/api/v2.0/me/subscriptions

我已通过 Azure AD 使用基于证书的身份验证,使用以下代码获取令牌:

AuthenticationContext authContext = new AuthenticationContext("https://login.microsoftonline.com/mytenant/oauth2/v2.0/token");
AuthenticationResult authResult = await authContext.AcquireTokenAsync("https://outlook.office365.com/", certificate);

在调用订阅 API 时,我收到一个 Forbidden 错误,响应如下:

x-ms-diagnostics: 2000008;reason="OAuth2 AccessTokens for app-only require that the target mailbox is explicitly specified with the api call";error_category="invalid_grant"

能否请您帮我解决哪里出错或如何调试/解决此错误。

提前致谢

【问题讨论】:

    标签: c# azure outlook office365 office365api


    【解决方案1】:

    由于您使用的是App-only 令牌,API 要求您在 URI 中明确指定目标邮箱。 例如:https://outlook.office365.com/api/v2.0/Users(foo@bar.com)/subscriptions

    me 仅在目标邮箱与经过身份验证的用户相同的情况下才有用。但是,在仅应用程序的情况下,没有经过身份验证的用户,您是否必须明确。

    【讨论】:

      猜你喜欢
      • 2023-04-10
      • 1970-01-01
      • 2020-01-11
      • 1970-01-01
      • 2017-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多