无法解析与请求一起提交的OAuth令牌 [英] OAuth token submitted with the request can not be parsed

查看:262
本文介绍了无法解析与请求一起提交的OAuth令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现一个导入用户在Office 365中具有的事件的客户端,以便可以轻松地在公司的应用程序中显示这些事件.

I'm trying to implement a client that imports the events that a user has in Office 365 so that I can easily display them in the company's application.

我设法使用户通过他/她的Office 365帐户进行身份验证并批准我的应用程序,还获得了AccessToken,但是当我尝试使用令牌从API检索事件时,我得到了401 HTTP错误代码,没有正文,并且在标题中我有以下内容:

I managed to get the user to authenticate with his / her Office 365 account and to approve my application and to also get an AccessToken, but when I try to use the token to retrieve the events from the API, I get a 401 HTTP error code, no body and in the headers I have this:

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获得的令牌具有以下正文:

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]

我从上述调用中收到的令牌,通过授权标头发送到 https://outlook.office.com/api/v2.0/me/events 像这样:

The token I receive from the above call, I send through the Authorization header to https://outlook.office.com/api/v2.0/me/events like so:

Authorization: Bearer [access-token]

我从此呼叫中获得的响应状态是401未经授权,我得到一个空的正文,并且标头如下所示:

The response status I get from this call is 401 Unauthorized, I get an empty body and the headers are like so:

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"

你能告诉我我在做什么错吗?

Can you please tell me what I'm doing wrong?

推荐答案

我设法解决了我遇到的问题.

I managed to fix the problem I had.

供以后参考,问题是我没有告诉 https://login. microsoftonline.com/common/oauth2/token 端点,我需要该令牌用于什么.

For future reference, the problem was that I wasn't telling the https://login.microsoftonline.com/common/oauth2/token endpoint what I needed the token for.

我必须提供一个资源参数,其中包含我要查询的资源的基本URL. 就我而言,它是 https://outlook.office365.com .

I had to provide a resource parameter with the base url of the resource I was going to interogate after. In my case, it was https://outlook.office365.com.

这篇关于无法解析与请求一起提交的OAuth令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆