After Step 1 of the oauth2 dance I can retreive a code in the redirect URL. This works fine. But then,
I've got an 'com.google.api.client.http.HttpResponseException: 400 Bad Request' error
trying to get the accessTokenResponse. Any idea why ?
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();
}
this is the line that triggers the error :
AccessTokenResponse accessTokenResponse = request.execute();
I'm using 'com.google.api.client.auth.oauth2.draft10.AccessTokenRequest.AuthorizationCodeGrant'
Should I use somehting else maybe ? any suggestion ?