OAuth与Office 365 SOAP返回”;受众声明值无效";
我一直在尝试使用OAuth将Office 365 Exchange服务集成到web应用程序中。我们已经为内部部署进行了集成,该集成可与基本的[username:password]身份验证一起使用 授权使用: /oauth2/authorize?response\u type=code&prompt=APP\u id=[APP\u id]和redirect\u uri=[URL] 使用获取令牌: 邮递 /oauth2/token 正文: 授予\类型=授权\代码和代码=[code]&重定向\ url=[url]&范围= 我成功地得到了一个代币 我在Azure应用程序注册上设置的应用程序权限为: Microsoft图形权限 读写用户和共享日历 读取用户和共享日历 以用户身份发送邮件 读取用户日历 拥有对用户日历的完全访问权限 Office 365 Exchange联机权限 读取用户和共享日历 读写用户和共享日历 以用户身份发送邮件 读取用户日历 读写用户日历 使用我获得的令牌,我尝试使用创建一个事件; 标题:OAuth与Office 365 SOAP返回”;受众声明值无效";,soap,outlook,office365,exchangewebservices,Soap,Outlook,Office365,Exchangewebservices,我一直在尝试使用OAuth将Office 365 Exchange服务集成到web应用程序中。我们已经为内部部署进行了集成,该集成可与基本的[username:password]身份验证一起使用 授权使用: /oauth2/authorize?response\u type=code&prompt=APP\u id=[APP\u id]和redirect\u uri=[URL] 使用获取令牌: 邮递 /oauth2/token 正文: 授予\类型=授权\代码和代码=[code]&重定向\ url
- POST/EWS/Exchange.asmx HTTP/1.1
- 主机:outlook.office365.com
- 客户端请求\u id:[随机\u guid]
- 用户代理:APPName
- 授权:持票人[代币]
谢谢大家! 对于EWS,如果您试图使用AppOnly令牌,您应该请求的范围为或。其他受约束的作用域对EWS无效,因为它在这方面有点遗留API 我试过这个,但运气不好。还是一样的错误。我注意到一件事,error表示授权,error=“无效”。但我尝试授权应用程序“”。看起来您正在使用v1端点?如果是这样,您不应该使用范围,因为这在v1中是无效的,而是使用resource=您的最后一条注释有效。非常感谢你。如果你更新你的答案,我会把它标记为解决方案。
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2016"/>
</soap:Header>
<soap:Body>
<m:CreateItem SendMeetingInvitations="SendToAllAndSaveCopy">
<m:Items>
<t:CalendarItem>
<t:Subject>Test Event</t:Subject>
<t:Body BodyType="HTML">Test Body</t:Body>
<t:Start>2018-11-17T08:00:00.000</t:Start>
<t:End>2018-11-17T09:00:00.000</t:End>
<t:StartTimeZone Id="Pacific Standard Time"/>
<t:EndTimeZone Id="Pacific Standard Time"/>
</t:CalendarItem>
</m:Items>
</m:CreateItem>
Server →Microsoft-IIS/10.0
request-id →b6d17647-5285-4c40-9087-3875958750b2
X-CalculatedFETarget →MWHPR1601CU001.internal.outlook.com
X-BackEndHttpStatus →401
X-BackEndHttpStatus →401
Set-Cookie →exchangecookie=947fe20a28e842068b3fe78a71b4e15b; path=/
X-FEProxyInfo →MWHPR1601CA0011.NAMPRD16.PROD.OUTLOOK.COM
X-CalculatedBETarget →MWHPR2001MB1823.namprd20.prod.outlook.com
X-RUM-Validated →1
x-ms-diagnostics →2000003;reason="The audience claim value is invalid 'aud'.";error_category="invalid_resource"
X-BeSku →Gen9
X-DiagInfo →MWHPR2001MB1823
X-BEServer →MWHPR2001MB1823
X-FEServer →MWHPR1601CA0011
X-FEServer →BYAPR05CA0077
X-Powered-By →ASP.NET
WWW-Authenticate →Bearer client_id="00000002-0000-0ff1-ce00-000000000000", trusted_issuers="00000001-0000-0000-c000-000000000000@*", token_types="app_asserted_user_v1 service_asserted_app_v1", authorization_uri="https://login.windows.net/common/oauth2/authorize", error="invalid_token",Basic Realm="",Basic Realm="",Basic Realm=""
Date →Wed, 14 Nov 2018 22:07:28 GMT
Content-Length →0