403 Forbidden response Google API

1.3k views Asked by At

I am using the Google+ Api to create new circles for users. When I try and to a POST request I get a response like this:

 {
  "error": {
    "errors": [
      {
        "domain": "global",
        "reason": "forbidden",
        "message": "Forbidden"
      }
    ],
    "code": 403,
    "message": "Forbidden"
  }
}

This is the same response I get when I try to do the same request using Googles own Google API explorer https://developers.google.com/+/domains/api/circles/insert which seems wierd to me. Why am I getting a forbidden response from googles own api expolrer? Could this be something wrong on their end?

I am using scribe OAuth library together with yincrash Google2Api https://github.com/fernandezpablo85/scribe-java

https://gist.github.com/yincrash/2465453

The request is created like this in an AsyncTask

OAuthService service = new ServiceBuilder()
                .provider(Google2API.class)
                .apiKey(GOOGLE_CLIENT_ID)
                .apiSecret(GOOGLE_CLIENT_KEY)
                .callback(GOOGLE_CALLBACK)
                .scope(SCOPE_WRITE)
                .scope(SCOPE_ME)
                .build();

        String postUrl = "https://www.googleapis.com/plusDomains/v1/people/me/circles";


        String requestBody = "{\n" +
                "  \"displayName\": \"Circle Name\",\n" +
                "  \"description\": \"Circle with people you added\"" +
                "}";

        Token accessToken = new Token(sharedPreferences.getString(PREF_GOOGLE_KEY, ""), "");
        OAuthRequest request = new OAuthRequest(Verb.POST, postUrl);
        request.addHeader("Content-Type", "application/json")
        request.addPayload(requestBody);
        service.signRequest(accessToken, request);
        Response response = request.send();

It works fine to login and I have the access token saved.

0

There are 0 answers