AppEngine - 远程API返回401和太多身份验证 [英] AppEngine - Remote API returning 401 and too-many-auth

查看:283
本文介绍了AppEngine - 远程API返回401和太多身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b

  os.environ ['p' GOOGLE_APPLICATION_CREDENTIALS'] =... / path / to / key
remote_api_stub.ConfigureRemoteApiForOAuth(
server.encode('ascii'),path,secure = True

其中路径/ to / key 指向JSON文件在Google Cloud(测试版), API管理器 - >凭证 - >添加凭证 - >服务帐户中创建。服务帐户可以编辑每个权限面板。



当我运行此操作时,一个401(如在App Engine日志查看器中报告):

$ p
文件/ usr / local / share / app-engine-python / google / appengine / ext / remote_api / remote_api_stub.py,第768行,在ConfigureRemoteApiForOAuth
rpc_server_factory = rpc_server_factory)
文件/ usr / local / share / app-engine-python / google / appengine / ext /remote_api/remote_api_stub.py,第835行,在ConfigureRemoteApi
app_id = GetRemoteAppIdFromServer(server,path,rtok)
文件/ usr / local / share / app-engine-python / google / appengine / ext / remote_api / remote_api_stub.py,第569行,位于GetRemoteAppIdFromServer
response = server.Send(path,payload = None,** urlargs)
文件/ usr / local / share / app-engine -python / google / appengine / tools / appengine_rpc_httplib2.py,第258行,发送
NeedAuth()
文件/ usr / local / share / app-eng / usr / local文件中的ine-python / google / appengine / tools / appengine_rpc_httplib2.py,第234行,在NeedAuth中
RaiseHttpError(url,response_info,response,'尝试过多验证。') /share/app-engine-python/google/appengine/tools/appengine_rpc_httplib2.py,第85行,在RaiseHttpError中
提升urllib2.HTTPError(url,response_info.status,msg,response_info,stream)
urllib2.HTTPError:HTTP错误401:未经授权尝试过多尝试。

我检查了正确的凭证,它似乎在 / google / appengine / ext / remote_api / remote_api_stub中设置。 py:760 并且应该传递给远程api。



app.yaml 具有基本设置 - remote_api:在下<内置



这个设置适用于本地 dev_appserver.py ,所以我认为问题出在Google服务器/云设置上。



我在 App引擎 - >设置 - >应用程序设置(Google Accounts API和Google Apps域)中尝试了两种身份验证方案。



我遵循 Google应用程序默认凭据尽我所能,但也许我错过了什么?



也许值得注意的是,从命令行:

  $ GOOGLE_APPLICATIO N_CREDENTIALS =〜/路径至键
remote_api_shell.py -s APPID.appspot.com --secure APPID

也给出相同的401异常。

解决方案

好的, p>


  1. 转至appspot.com管理页面。

  2. 在应用程序设置下启用云集成
  3. >
  4. 新的云端控制台页面API管理器中创建一个新的服务帐户(现有服务帐户似乎无法工作)
  5. <敲击>切换到 remote_api_stub.ConfigureRemoteApiFromServer - 进一步检查时,看起来 ConfigureRemoteApiForOAuth 正常工作。 / li>

至少在完成上述的访问工作后,如预期的那样。



其他类似位置的人发现这种帮助。



编辑这可能与此线程上讨论的问题有关: https://groups.google.com/forum/?utm_medium = email& utm_source = footer#!msg / google-cloud-insiders / ohnp1XAOdiM / KrQF8_DAAAAJ


I am trying to connect to an AppEngine instance with the remote API with something like this:

os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = ".../path/to/key"
remote_api_stub.ConfigureRemoteApiForOAuth(
    server.encode('ascii'), path, secure=True
)

Where the path/to/key points to a JSON file created in the Google Cloud (Beta), API Manager -> Credentials -> Add Credentials -> Service Account. The service account "Can edit" per the Permissions panel.

When I run this I get an error like this on the console, corresponding to a 401 (as reported in the App Engine log viewer):

  File "/usr/local/share/app-engine-python/google/appengine/ext/remote_api/remote_api_stub.py", line 768, in ConfigureRemoteApiForOAuth
    rpc_server_factory=rpc_server_factory)
  File "/usr/local/share/app-engine-python/google/appengine/ext/remote_api/remote_api_stub.py", line 835, in ConfigureRemoteApi
    app_id = GetRemoteAppIdFromServer(server, path, rtok)
  File "/usr/local/share/app-engine-python/google/appengine/ext/remote_api/remote_api_stub.py", line 569, in GetRemoteAppIdFromServer
    response = server.Send(path, payload=None, **urlargs)
  File "/usr/local/share/app-engine-python/google/appengine/tools/appengine_rpc_httplib2.py", line 258, in Send
    NeedAuth()
  File "/usr/local/share/app-engine-python/google/appengine/tools/appengine_rpc_httplib2.py", line 234, in NeedAuth
    RaiseHttpError(url, response_info, response, 'Too many auth attempts.')
  File "/usr/local/share/app-engine-python/google/appengine/tools/appengine_rpc_httplib2.py", line 85, in RaiseHttpError
    raise urllib2.HTTPError(url, response_info.status, msg, response_info, stream)
urllib2.HTTPError: HTTP Error 401: Unauthorized Too many auth attempts.

I checked and the correct credentials seem to be set in /google/appengine/ext/remote_api/remote_api_stub.py:760 and should be passed to the remote api.

The app.yaml has the basic setting - remote_api: on under builtins.

This setup works for the local dev_appserver.py, so I am led to believe the problem is on the Google server/cloud settings.

I have tried both authentication schemes in App Engine -> Settings -> Application settings (Google Accounts API and Google Apps domain).

I followed the Google Application Default Credentials as fit as I could, but maybe I missed something?

It is probably also worth noting that from the command line:

$ GOOGLE_APPLICATION_CREDENTIALS=~/path-to-key
    remote_api_shell.py -s APPID.appspot.com --secure APPID

also gives the same 401 exception.

解决方案

Ok, so what seemed to be necessary was:

  1. Go to the appspot.com admin page.
  2. Under Application Settings, enable Cloud Integration
  3. Create a new service account in the new cloud console page API Manager (existing service accounts do not seem to work)
  4. Switch to remote_api_stub.ConfigureRemoteApiFromServer — on further inspection, it appears that ConfigureRemoteApiForOAuth works fine.

At least after performing the above access works as expected.

I hope others similarly situated find this helpful.

Edit This may be related to the issue discussed on this thread: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/google-cloud-insiders/ohnp1XAOdiM/KrQF8_DAAAAJ

这篇关于AppEngine - 远程API返回401和太多身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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