无法解析与请求一起提交的 OAuth 令牌
OAuth token submitted with the request can not be parsed
我正在尝试实现一个客户端,该客户端导入用户在 Office 365 中拥有的事件,以便我可以轻松地在公司的应用程序中显示它们。
我设法让用户使用他/她的 Office 365 帐户进行身份验证并批准我的申请并获得 AccessToken,但是当我尝试使用令牌从 API,我得到一个 401 HTTP 错误代码,没有 body,在 header 中我有这个:
Content-Length →0
Date →Thu, 17 Mar 2016 08:56:00 GMT
Server →Microsoft-IIS/8.0
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=""
X-BEServer →DB4PR06MB522
X-BackEndHttpStatus →401
X-CalculatedBETarget →DB4PR06MB522.eurprd06.prod.outlook.com
X-DiagInfo →DB4PR06MB522
X-FEServer →AM3PR06CA022
X-Powered-By →ASP.NET
request-id →de1963bc-36df-4473-81f6-66ec37e8b415
x-ms-diagnostics →2000001;reason="OAuth token submitted with the request can not be parsed.";error_category="invalid_token"
我从 https://login.microsoftonline.com/common/oauth2/token 获得的令牌具有以下 body:
grant_type=authorization_code
redirect_uri=https://example.com/redirect-uri
client_id=XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXX
client_secret=[my-client-secret]
code=[code-received-from-user-auth]
我从上述调用中收到的令牌,我通过授权 header 发送到 https://outlook.office.com/api/v2.0/me/events,如下所示:
Authorization: Bearer [access-token]
我从这个调用中得到的响应状态是 401 Unauthorized,我得到一个空的 body 并且 headers 是这样的:
Content-Length →0
Date →Thu, 17 Mar 2016 08:56:00 GMT
Server →Microsoft-IIS/8.0
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=""
X-BEServer →DB4PR06MB522
X-BackEndHttpStatus →401
X-CalculatedBETarget →DB4PR06MB522.eurprd06.prod.outlook.com
X-DiagInfo →DB4PR06MB522
X-FEServer →AM3PR06CA022
X-Powered-By →ASP.NET
request-id →de1963bc-36df-4473-81f6-66ec37e8b415
x-ms-diagnostics →2000001;reason="OAuth token submitted with the request can not be parsed.";error_category="invalid_token"
你能告诉我我做错了什么吗?
我设法解决了我遇到的问题。
为了将来参考,问题是我没有告诉 https://login.microsoftonline.com/common/oauth2/token 端点我需要令牌的目的。
我必须提供一个资源参数,其中包含我要查询的资源的基数 url。
就我而言,它是 https://outlook.office365.com.
我正在尝试实现一个客户端,该客户端导入用户在 Office 365 中拥有的事件,以便我可以轻松地在公司的应用程序中显示它们。
我设法让用户使用他/她的 Office 365 帐户进行身份验证并批准我的申请并获得 AccessToken,但是当我尝试使用令牌从 API,我得到一个 401 HTTP 错误代码,没有 body,在 header 中我有这个:
Content-Length →0
Date →Thu, 17 Mar 2016 08:56:00 GMT
Server →Microsoft-IIS/8.0
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=""
X-BEServer →DB4PR06MB522
X-BackEndHttpStatus →401
X-CalculatedBETarget →DB4PR06MB522.eurprd06.prod.outlook.com
X-DiagInfo →DB4PR06MB522
X-FEServer →AM3PR06CA022
X-Powered-By →ASP.NET
request-id →de1963bc-36df-4473-81f6-66ec37e8b415
x-ms-diagnostics →2000001;reason="OAuth token submitted with the request can not be parsed.";error_category="invalid_token"
我从 https://login.microsoftonline.com/common/oauth2/token 获得的令牌具有以下 body:
grant_type=authorization_code
redirect_uri=https://example.com/redirect-uri
client_id=XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXX
client_secret=[my-client-secret]
code=[code-received-from-user-auth]
我从上述调用中收到的令牌,我通过授权 header 发送到 https://outlook.office.com/api/v2.0/me/events,如下所示:
Authorization: Bearer [access-token]
我从这个调用中得到的响应状态是 401 Unauthorized,我得到一个空的 body 并且 headers 是这样的:
Content-Length →0
Date →Thu, 17 Mar 2016 08:56:00 GMT
Server →Microsoft-IIS/8.0
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=""
X-BEServer →DB4PR06MB522
X-BackEndHttpStatus →401
X-CalculatedBETarget →DB4PR06MB522.eurprd06.prod.outlook.com
X-DiagInfo →DB4PR06MB522
X-FEServer →AM3PR06CA022
X-Powered-By →ASP.NET
request-id →de1963bc-36df-4473-81f6-66ec37e8b415
x-ms-diagnostics →2000001;reason="OAuth token submitted with the request can not be parsed.";error_category="invalid_token"
你能告诉我我做错了什么吗?
我设法解决了我遇到的问题。
为了将来参考,问题是我没有告诉 https://login.microsoftonline.com/common/oauth2/token 端点我需要令牌的目的。
我必须提供一个资源参数,其中包含我要查询的资源的基数 url。 就我而言,它是 https://outlook.office365.com.