403禁止回复Google API

时间:2015-08-07 14:29:43

标签: android google-api google-plus http-status-code-403 google-plus-domains

我正在使用Google+ Api为用户创建新的圈子。当我尝试POST请求时,我得到这样的回复:

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

当我尝试使用Googles自己的Google API资源管理器https://developers.google.com/+/domains/api/circles/insert执行相同的请求时,我得到的回复与我看起来很奇怪。为什么我从谷歌自己的api expolrer得到禁止回复?这可能是他们的错误吗?

我正在使用scribe OAuth库和yincrash Google2Api https://github.com/fernandezpablo85/scribe-java

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

请求在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();

登录时工作正常,我保存了访问令牌。

0 个答案:

没有答案