Reputation: 1834
I've been following the steps in the migration tutorial:
https://developers.google.com/accounts/docs/OAuth_ref#migration
I am sending a correct "Authentication" header but all I get is:
{ "error" : "invalid_token" }
The Oauth token is valid, I can access the GData services from my app just fine.
This is my code for the migration (simplified):
com.google.gdata.client.authn.oauth.OAuthParameters oauthParameters = new com.google.gdata.client.authn.oauth.OAuthParameters();
com.google.gdata.client.authn.oauth.OAuthHmacSha1Signer signer = new com.google.gdata.client.authn.oauth.OAuthHmacSha1Signer();
oauthParameters.setOAuthConsumerKey(oauthConsumerKey);
oauthParameters.setOAuthConsumerSecret(oauthConsumerSecret);
oauthParameters.setOAuthToken(account.getOAuthToken());
oauthParameters.setOAuthTokenSecret(account.getOAuthTokenSecret());
OAuthHelper oauthHelper = new GoogleOAuthHelper(signer);
String header = authHelper.getAuthorizationHeader("http://www.sharedgroups.com", "POST", oauthParameters);
HTTPRequest request = new HTTPRequest(new URL("https://accounts.google.com/o/oauth2/token"), HTTPMethod.POST);
String clientId = "<myid>.apps.googleusercontent.com";
String clientSecret = "<mysecret>";
String payload = "grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Amigration%3Aoauth1&client_id="+clientId+"&client_secret="+clientSecret;
request.addHeader(new HTTPHeader("Authorization", header));
request.setPayload(payload.getBytes());
URLFetchService urlFetchService = URLFetchServiceFactory.getURLFetchService();
HTTPResponse response = urlFetchService.fetch(request);
resp.getWriter().println("RESPONSE="+new String(response.getContent()));
Upvotes: 2
Views: 839
Reputation: 1430
We have made a few changes to the validation pieces of the OAuth1->OAuth2 token migration. Would you mind checking your migration flows again and updating this thread with the results?
Upvotes: 1