we are using https://www.googleapis.com/appsmarket/v2/upgradableApp to migrate the oauth1.0 app to oauth2.0 app.
We are referring to https://developers.google.com/apps-marketplace/v1migratev2
while making the call we are getting "Invalid OAuth Header" error (401)
We are using consumer key and consumer secret alone. we are not using any token.
I am sure that we are missing something here. But not sure what it is. Any pointers to this issue will help us.
Thanks in advance.
Here is the sample code
HttpClient client = new HttpClient();
PutMethod method = new PutMethod("https://www.googleapis.com/appsmarket/v2/upgradableApp///");
method.addRequestHeader("Authorization", "oAuth");
method.addRequestHeader("Consumer Key","");
method.addRequestHeader("Consumer Key Secret","");
try {
int status = client.executeMethod(method);
System.out.println("status:" + status);
System.out.println("response:" + method.getResponseBodyAsString());
}
catch (HttpException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
status:::401 response::{"error":{"errors":[{"domain":"global","reason":"authError","message":"Invalid OAuth > header","locationType":"header","location":"Authorization"}],"code":401,"message":"In valid OAuth header"}}
We tried with the following code using OAuth 1.0 API for Google and it worked fine.
OAuthRequest request = new OAuthRequest(Verb.PUT, api.getUpdateDomainEndpoint(listingId, chromeWSId, domain));
request.addOAuthParameter(OAuthConstants.TIMESTAMP, api.getTimestampService().getTimestampInSeconds());
request.addOAuthParameter(OAuthConstants.NONCE, api.getTimestampService().getNonce());
request.addOAuthParameter(OAuthConstants.CONSUMER_KEY, config.getApiKey());
request.addOAuthParameter(OAuthConstants.SIGN_METHOD, api.getSignatureService().getSignatureMethod());
request.addOAuthParameter(OAuthConstants.VERSION, getVersion());
request.addOAuthParameter(OAuthConstants.SIGNATURE, getSignature(request, token));
String oauthHeader = api.getHeaderExtractor().extract(request);
request.addHeader(OAuthConstants.HEADER, oauthHeader);