无法刷新访问令牌:响应是“unauthorized_client” [英] Unable to refresh access token : response is "unauthorized_client"
问题描述
<400>错误请求
{error:unauthorized_client}
从Google令牌URI:
{
error:invalid_request
}
我读过这个答案 以及官方的Google文档(它描述了 POST
请求应该如何显示),而且我没有看到任何
我抓住了我的 POST
请求(取消了秘密):
POST / SHOWMERAWPOST HTTP / 1.1
用户代理:Google-HTTP-Java-Client / 1.10.3-beta(gzip)
Pragma: no-cache
主机:requestb.in
内容类型:application / x-www-form-urlencoded; charset = UTF-8
Content-Length:175
连接:keep-alive
Cache-Control:no-cache
Accept-Encoding:gzip
Accept:text / html,image / gif,image / jpeg,*; q = .2,* / *; q = .2
grant_type = refresh_token& refresh_token = ******& client_id = *******。apps.googleusercontent.com& client_secret = ******
发送请求的Java代码:
<$ (),新的GenericUrl(
getSecrets()。getDetails()。getTokenUri()),REFRESH_TOKEN); //获得一个新的RefreshTokenRequest(new NetHttpTransport(),new JacksonFactory
req.set(client_id,getSecrets()。getDetails()。getClientId());
req.set(client_secret,getSecrets()。getDetails()。getClientSecret());
TokenResponse response = req.execute();
有什么不对吗?
解决方案我在OAuth2操场创建了访问和刷新令牌,然后我将它们复制到我的应用程序中。不允许有不同的客户端进行自动化和令牌刷新。
I am getting an error when I try to refresh access token:
400 Bad Request
{error : "unauthorized_client"}
From the Google token URI:
{
"error" : "invalid_request"
}
I read this answer here and the official Google documentation (which describes how a POST
request should look) and I don't see any difference.
I captured my POST
request (secrets removed):
POST /SHOWMERAWPOST HTTP/1.1
User-Agent: Google-HTTP-Java-Client/1.10.3-beta (gzip)
Pragma: no-cache
Host: requestb.in
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Content-Length: 175
Connection: keep-alive
Cache-Control: no-cache
Accept-Encoding: gzip
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
grant_type=refresh_token&refresh_token=******&client_id=*******.apps.googleusercontent.com&client_secret=******
Java code which sends the request:
RefreshTokenRequest req = new RefreshTokenRequest(new NetHttpTransport(), new JacksonFactory(), new GenericUrl(
getSecrets().getDetails().getTokenUri()), REFRESH_TOKEN);
req.set("client_id", getSecrets().getDetails().getClientId());
req.set("client_secret", getSecrets().getDetails().getClientSecret());
TokenResponse response = req.execute();
Is there anything wrong?
I created access and refresh token in OAuth2 playground and then i copied them to my app. It`s not allowed to have different clients for autorization and for token refresh.
这篇关于无法刷新访问令牌:响应是“unauthorized_client”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!