在oauth2 dance的第1步之后,我可以在重定向URL中检索代码。这工作正常。但随后,Stocktwits API - AuthorizationCodeGrant HttpResponseException:400 Bad Request
我有一个 'com.google.api.client.http.HttpResponseException:400错误的请求' 的错误
试图让accessTokenResponse。任何想法为什么?
AuthorizationCodeGrant request = new AuthorizationCodeGrant(new NetHttpTransport(),
new JacksonFactory(),
OAuth2ClientCredentials.ACCESS_TOKEN_URL,
OAuth2ClientCredentials.CLIENT_ID,
OAuth2ClientCredentials.CLIENT_SECRET,
code,
OAuth2ClientCredentials.REDIRECT_URI);
try {
AccessTokenResponse accessTokenResponse = request.execute();
CredentialStore credentialStore = new SharedPreferencesCredentialStore(prefs);
credentialStore.write(accessTokenResponse);
} catch (IOException e) {
Log.e(TAG, "error= "+e);
e.printStackTrace();
}
这是触发错误的行:
AccessTokenResponse accessTokenResponse = request.execute();
我使用 'com.google.api.client.auth.oauth2.draft10.AccessTokenRequest.AuthorizationCodeGrant'
我应该使用别人吗?任何建议?
您可以尝试手动请求授权令牌并返回代码并查看是否有效。有关示例,请参阅http://stocktwits.com/developers/docs/api#oauth-token-docs。 – AdamB