c# - Office365 API : OAuth2 AccessTokens for app-only require that the

标签 c# azure outlook office365 office365api

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

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

我已使用 Azure AD 基于证书的身份验证来获取 token ,使用以下代码:

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

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

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"

您能帮我解决哪里出错或者如何调试/解决此错误吗?

提前致谢

最佳答案

由于您正在使用App-only API 需要您在 URI 中显式指定目标邮箱的 token 。 例如:https://outlook.office365.com/api/v2.0/Users(<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5e3831311e3c3f2c703d3133" rel="noreferrer noopener nofollow">[email protected]</a>)/subscriptions

me仅当目标邮箱与经过身份验证的用户相同时才有用。但是,如果仅使用应用程序,则没有经过身份验证的用户,您是否必须明确说明。

关于c# - Office365 API : OAuth2 AccessTokens for app-only require that the,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41184026/

相关文章:

c# - 为什么 AccessViolationException 不能被 .NET4.0 捕获

c# - 如何减小从 ASP.net 呈现的 html 的大小?

windows - 如何从启动任务访问Azure本地存储?

iCal 订阅的 Outlook 刷新间隔 (webcal ://)

javascript - Outlook 365 垂直任务 Pane 处于阅读模式?

html - 使用替换删除文本

c# - 如何检测wpf中的加号?

C# Windows 窗体 ComboBox 下拉内容

azure - 使用 Azure 数据工厂进行 API 调用时出现错误 500

azure ftp 到 dropbox 连接器无法在逻辑应用中工作