所有请求都返回403未授权 [英] All Requests return 403 Unauthorized

查看:533
本文介绍了所有请求都返回403未授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图与云数据存储一起工作 - 我创建了一个appengine项目,可在 https://cloud.google.com/console#/

通过云端控制台,我浏览了API,然后关闭数据存储API。然后我注册了一个应用程序(Web应用程序,通用)并生成了一个证书。我已经确保由此生成的电子邮件位于'Team'列表中'Can Edit'许可。



毕竟,我产生的任何请求都返回403 。对其他API(如预测API)的请求可以正常工作。数据存储从我的代码库(使用php api)或从api explorer返回403。



下面是从PHP客户端生成的HTTP请求的转储。

  object(Google_HttpRequest)[15] 
private'batchHeaders'=>
array(size = 4)
'Content-Type'=>字符串'application / http'(长度= 16)
'Content-Transfer-Encoding'=>字符串'binary'(长度= 6)
'MIME-Version'=>字符串'1.0'(长度= 3)
'Content-Length'=> string''(length = 0)
protected'url'=> string'https://www.googleapis.com/datastore/v1beta1/datasets/madlab-sandbox/lookup'(length = 75)
protected'requestMethod'=>字符串'POST'(长度= 4)
保护'requestHeaders'=>
array(size = 3)
'content-type'=>字符串'application / json; charset = UTF-8'(长度= 31)
'content-length'=> int 62
'authorization'=>字符串'Bearer ya29.AHES6ZSfJmWHLNIrPwQA7wZ3miGCMgxvmUmYl65mfw9J2_v8KgmLMyJV'(length = 68)
protected'postBody'=> string'{keys:[{path:[{id:5629499534213120,kind:topic}]}]}'(length = 62)
protected'userAgent'= > string'test google-api-php-client / 0.6.4'(length = 32)
protected'responseHttpCode'=> int 403
protected'responseHeaders'=>
array(size = 9)
'content-type'=>字符串'application / json; charset = UTF-8'(长度= 31)
'date'=> 'Fri,26 Jul 2013 15:26:13 GMT'(length = 29)
'expires'=>字符串'Fri,2013年7月26日15:26:13 GMT'(长度= 29)
'cache-control'=> string'private,max-age = 0'(length = 18)
'x-content-type-options'=>字符串'nosniff'(长度= 7)
'x-frame-options'=>字符串'SAMEORIGIN'(长度= 10)
'x-xss-protection'=>字符串'1; mode = block'(length = 13)
'server'=>字符串'GSE'(长度= 3)
'transfer-encoding'=>字符串'chunked'(长度= 7)
保护'responseBody'=>字符串'{
错误:{
错误:[
{
domain:global,
reason:PERMISSION_DENIED,
讯息:未经授权。
}
],
code:403,
message:未授权。
}
}
'(length = 182)
public'accessKey'=> null


解决方案

解决此问题:




  • 访问 Google Cloud Console
  • 点击现有的Cloud项目。

  • 点击设置菜单下的团队。

  • 找到与您的证书相对应的电子邮件地址(它将是一个约45个字符的字符串,然后是@ developer.gserviceaccount.com)。
  • 删除然后重新添加此电子邮件地址作为


我已经在Cloud Datastore公共问题追踪器上提交了这个文件:
https://github.com/GoogleCloudPlatform/google-cloud-datastore/issues/10



请检查更新。


I'm trying to work with the cloud datatstore - I've created an appengine project, which is viewable at https://cloud.google.com/console#/.

Through the cloud console, I've navigated to APIs, and turned off and back on the datastore API. I've then registered an app (web application, generic) and generated a certificate. I've ensured that the email generated from that is in the 'Teams' list with 'Can Edit' permission.

After all this, any requests I generate are returning 403. Requests to other APIs, such as the prediction API, are working okay. The datastore is returning 403 both from my codebase (using php api) or from the api explorer.

Below is a dump of the HTTP Request generated from the PHP client. Any help would be greatly appreciated!

  object(Google_HttpRequest)[15]
  private 'batchHeaders' => 
    array (size=4)
      'Content-Type' => string 'application/http' (length=16)
      'Content-Transfer-Encoding' => string 'binary' (length=6)
      'MIME-Version' => string '1.0' (length=3)
      'Content-Length' => string '' (length=0)
  protected 'url' => string 'https://www.googleapis.com/datastore/v1beta1/datasets/madlab-sandbox/lookup' (length=75)
  protected 'requestMethod' => string 'POST' (length=4)
  protected 'requestHeaders' => 
    array (size=3)
      'content-type' => string 'application/json; charset=UTF-8' (length=31)
      'content-length' => int 62
      'authorization' => string 'Bearer ya29.AHES6ZSfJmWHLNIrPwQA7wZ3miGCMgxvmUmYl65mfw9J2_v8KgmLMyJV' (length=68)
  protected 'postBody' => string '{"keys":[{"path":[{"id":"5629499534213120","kind":"topic"}]}]}' (length=62)
  protected 'userAgent' => string 'test google-api-php-client/0.6.4' (length=32)
  protected 'responseHttpCode' => int 403
  protected 'responseHeaders' => 
    array (size=9)
      'content-type' => string 'application/json; charset=UTF-8' (length=31)
      'date' => string 'Fri, 26 Jul 2013 15:26:13 GMT' (length=29)
      'expires' => string 'Fri, 26 Jul 2013 15:26:13 GMT' (length=29)
      'cache-control' => string 'private, max-age=0' (length=18)
      'x-content-type-options' => string 'nosniff' (length=7)
      'x-frame-options' => string 'SAMEORIGIN' (length=10)
      'x-xss-protection' => string '1; mode=block' (length=13)
      'server' => string 'GSE' (length=3)
      'transfer-encoding' => string 'chunked' (length=7)
  protected 'responseBody' => string '{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "PERMISSION_DENIED",
    "message": "Unauthorized."
   }
  ],
  "code": 403,
  "message": "Unauthorized."
 }
}
' (length=182)
  public 'accessKey' => null

解决方案

To work around this issue:

  • Visit the Google Cloud Console.
  • Click on your existing Cloud project.
  • Click on "Teams" under the settings menu.
  • Find the email address corresponding to your certificate (it will be a ~45 character string followed by @developer.gserviceaccount.com).
  • Remove and then re-add this email address as a member of your project.

I've filed this on the Cloud Datastore public issue tracker: https://github.com/GoogleCloudPlatform/google-cloud-datastore/issues/10

Please check there for updates.

这篇关于所有请求都返回403未授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆