无法刷新访问令牌:响应为“unauthorized_client"; [英] Unable to refresh access token : response is "unauthorized_client"
问题描述
当我尝试刷新访问令牌时出现错误:
I am getting an error when I try to refresh access token:
400 错误请求
{错误:unauthorized_client"}
{error : "unauthorized_client"}
来自 Google 令牌 URI:
From the Google token URI:
{
"error" : "invalid_request"
}
我读了这个答案 here 和 Google 官方文档(描述了 POST
请求的外观),我看不出任何区别.
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.
我捕获了我的 POST
请求(已删除机密):
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代码:
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();
有什么问题吗?
推荐答案
我在 OAuth2 playground 中创建了访问和刷新令牌,然后将它们复制到我的应用程序中.不允许有不同的客户端进行授权和令牌刷新.
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屋!