2015-10-13 19 views
0

我调用这个方法:com.google.api.client.auth.oauth2.TokenResponseException:400错误的请求

GoogleTokenResponse accessResposnse = new GoogleAuthorizationCodeTokenRequest(httpTransport, jsonFactory, 
       clientId, clientSecret, authorizationUrl, redirectUrl).execute(); 

其中authorizationUrl是:

String authorizationUrl = new GoogleAuthorizationCodeRequestUrl(clientId, redirectUrl, scope).setAccessType("offline").setState("security_token").setResponseTypes(responseType).build(); 

但它给我的错误:

com.google.api.client.auth.oauth2.TokenResponseException: 400 Bad Request { "error" : "invalid_grant" }

我错过了之间的任何一步? 另外,如果我想调用这个函数:

AuthorizationCodeResponseUrl authoUrl = new AuthorizationCodeResponseUrl(redirectUrl); 

它抛出java.lang.IllegalArgumentException

回答

0

这可能是因为你的刷新令牌过期..你想刷新你的访问令牌使用过期刷新令牌或使用过期的刷新令牌进行api调用? - 如果是这样你需要让你的用户重新认证..