[英]simple-oauth2 throws "The content-type is not JSON compatible" on token refresh
I'm using simple-oauth2 in this example to query Microsoft Graph.我在此示例中使用 simple-oauth2 来查询 Microsoft Graph。 All works well so far.
到目前为止一切正常。 But when I try to refresh the access token
var newToken = await storedToken.refresh();
但是当我尝试刷新访问令牌
var newToken = await storedToken.refresh();
, I get an error: ,我收到一个错误:
The content-type is not JSON compatible
内容类型与 JSON 不兼容
This is thrown in wreck
's index.js
and it seems like there is no content-type
set in the headers, while the mode
is set to strict
.这是在
wreck
的index.js
抛出的,似乎标题中没有设置content-type
,而mode
设置为strict
。 The problem is, that I have no idea how to change this or why this is happening.问题是,我不知道如何改变这一点或为什么会发生这种情况。 It only happens on
refresh()
.它只发生在
refresh()
。
I figured this is a configuration problem.我认为这是一个配置问题。 The sample provides the config as follows
示例提供的配置如下
OAUTH_AUTHORITY=https://login.microsoftonline.com/common
OAUTH_ID_METADATA=/v2.0/.well-known/openid-configuration
OAUTH_AUTHORIZE_ENDPOINT=/oauth2/v2.0/authorize
OAUTH_TOKEN_ENDPOINT=/oauth2/v2.0/token
wreck uses Url.URL to combine OAUTH_AUTHORITY
with OAUTH_TOKEN_ENDPOINT
which results in https://login.microsoftonline.com/oauth2/v2.0/token
and therefore loses common
. wreck 使用Url.URL将
OAUTH_AUTHORITY
与OAUTH_TOKEN_ENDPOINT
组合OAUTH_AUTHORITY
,这导致https://login.microsoftonline.com/oauth2/v2.0/token
并因此失去了common
. This results in a 404
and therefore no JSON response anymore.这会导致
404
,因此不再有 JSON 响应。
I changed the config slightly and removed the leading slashes from the relative paths and added a trailing slash to the base URL.我稍微更改了配置并从相对路径中删除了前导斜杠,并在基本 URL 中添加了尾随斜杠。
OAUTH_AUTHORITY=https://login.microsoftonline.com/common/
OAUTH_ID_METADATA=/v2.0/.well-known/openid-configuration
OAUTH_AUTHORIZE_ENDPOINT=oauth2/v2.0/authorize
OAUTH_TOKEN_ENDPOINT=oauth2/v2.0/token
So that OAUTH_TOKEN_ENDPOINT
is relative.所以
OAUTH_TOKEN_ENDPOINT
是相对的。 I have not figured why it worked for authorize though, but still works.我还没有弄清楚为什么它对授权有效,但仍然有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.