1

I am implementing google buzz API integration with android. I have successfully done with the OAuth and got the AccessToken. But when I am trying to POST the message on Buzz it replying me with Status 401 with below reponse.

{"error":{"errors":[{"domain":"global","reason":"invalid","message":"Token invalid - Invalid AuthSub token.","locationType":"header","location":"Authorization"}],"code":401,"message":"Token invalid - Invalid AuthSub token."}}

I used singpost library for oAuth and below is the code which I am using to post a message to BUZZ.

String serurl = "https://www.googleapis.com/buzz/v1/activities/@me/@self?key=@@KEY&alt=json";

serurl = serurl.replace("@@KEY", AppSettings.GOOGLE_API_KEY);

CommonsHttpOAuthConsumer consumer = new CommonsHttpOAuthConsumer(
                    AppSettings.GOOGLE_CONSUMER_KEY,
                    AppSettings.GOOGLE_CONSUMER_SECRET);
consumer.setMessageSigner(new HmacSha1MessageSigner());
consumer.setTokenWithSecret(destination.AccessToken,
                    destination.AccessTokenSecret);

String bstr = "{\"data\": {\"object\": {\"type\": \"note\",\"content\": \""
                + msg + "\"}}}";

HttpClient client = new DefaultHttpClient();

HttpPost method = new HttpPost(consumer.sign(serurl));

method.setHeader("Content-Type", "application/json");
method.addHeader("Accept", "application/json");

method.addHeader("Authorization", URLEncoder.encode(destination.AccessToken));


method.setEntity(new StringEntity(bstr, "UTF-8"));


HttpResponse response = client.execute(method);

final HttpEntity entity = response.getEntity();
String responseString = "";
if (entity != null) {
    InputStream inputStream = null;
    try {
         inputStream = entity.getContent();
          responseString = Utils.convertinputStreamToString(new Utils.FlushedInputStream(
                                    inputStream));
        } finally {
            if (inputStream != null) {
                inputStream.close();
            }
            entity.consumeContent();
        }
    }
}
    System.out.println(responseString);

And I am getting this reponse :

{"error":{"errors":[{"domain":"global","reason":"invalid","message":"Token invalid - Invalid AuthSub token.","locationType":"header","location":"Authorization"}],"code":401,"message":"Token invalid - Invalid AuthSub token."}}

Is anyone here who can help me on that.

Thanks.

Samdrain
  • 441
  • 4
  • 13
  • Have you added the relevant scopes ? – Abhinav Manchanda Aug 21 '11 at 13:11
  • @MichaelT Are you sure your edit will help? If im not wrong, Google Buzz is officially closed and I don't think this question will have a happy ending. – gian1200 Dec 11 '13 at 06:36
  • @gian1200 the goal of the edit cleanup isn't so much "this belongs in [tag:google-buzz] but rather that it *doesn't* belong in [tag:google] and/or [tag:buzz] which have different meanings (the google tag is currently a mess). –  Dec 11 '13 at 15:09

0 Answers0