我正在使用此 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/