自更新以来,appengine remote_api_shell无法使用应用程序默认凭据

Myl*_*les 6 python google-app-engine remoteapi gcloud

我最近将我的gcloud库从118.0.0更新到132.0.0,并且remote_api_shell立即不再有效.我经历了一些重新登录的排列,通过gcloud设置应用程序默认凭据,并使用服务帐户和环境变量.所有排列都失败,并显示相同的错误消息:

    Traceback (most recent call last):
  File "/Users/mbostwick/google-cloud-sdk/bin/remote_api_shell.py", line 133, in <module>
    run_file(__file__, globals())
  File "/Users/mbostwick/google-cloud-sdk/bin/remote_api_shell.py", line 129, in run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "/Users/mbostwick/google-cloud-sdk/platform/google_appengine/google/appengine/tools/remote_api_shell.py", line 160, in <module>
    main(sys.argv)
  File "/Users/mbostwick/google-cloud-sdk/platform/google_appengine/google/appengine/tools/remote_api_shell.py", line 156, in main
    oauth2=True)
  File "/Users/mbostwick/google-cloud-sdk/platform/google_appengine/google/appengine/tools/remote_api_shell.py", line 74, in remote_api_shell
    secure=secure, app_id=appid)
  File "/Users/mbostwick/google-cloud-sdk/platform/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 769, in ConfigureRemoteApiForOAuth
    rpc_server_factory=rpc_server_factory)
  File "/Users/mbostwick/google-cloud-sdk/platform/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 839, in ConfigureRemoteApi
    app_id = GetRemoteAppIdFromServer(server, path, rtok)
  File "/Users/mbostwick/google-cloud-sdk/platform/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 569, in GetRemoteAppIdFromServer
    response = server.Send(path, payload=None, **urlargs)
  File "/Users/mbostwick/google-cloud-sdk/platform/google_appengine/google/appengine/tools/appengine_rpc_httplib2.py", line 259, in Send
    NeedAuth()
  File "/Users/mbostwick/google-cloud-sdk/platform/google_appengine/google/appengine/tools/appengine_rpc_httplib2.py", line 235, in NeedAuth
    RaiseHttpError(url, response_info, response, 'Too many auth attempts.')
  File "/Users/mbostwick/google-cloud-sdk/platform/google_appengine/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.
Run Code Online (Sandbox Code Playgroud)

在通过131.0.0和130.0.0重新加速之后,我回到了118.0.0,重新登录并且一切正常.

我在更新gcloud之后没有更新正在运行的应用程序,因为我现在处于发布周期的中间,所以这可能是问题所在,但任何帮助都会受到赞赏.谢谢!

Eva*_*nes 11

TL; DR:这是在gcloud版本134中修复的

原答案:跑

gcloud auth application-default login --scopes=https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/userinfo.email
Run Code Online (Sandbox Code Playgroud)

现在你的远程shell应该再次工作.

详细信息:我认为128.0.0更新以及对gcloud auth login命令的更改已经破坏了这一点.旧令牌具有以下范围(根据Google的tokeninfo端点):

https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/appengine.admin https://www.googleapis.com/auth/compute https://www.googleapis.com/auth/plus.me
Run Code Online (Sandbox Code Playgroud)

gcloud auth application-default login没有任何选项的新令牌只有:

https://www.googleapis.com/auth/cloud-platform
Run Code Online (Sandbox Code Playgroud)

这是记录在案 gcloud auth application-default login --help

版本134详细信息:请求的范围现在是:

https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/cloud-platform
Run Code Online (Sandbox Code Playgroud)

请参阅https://groups.google.com/d/msg/google-appengine/ptc-76K6Kk4/9qr4601BBgAJ上的讨论

  • gcloud 134应该解决这个问题; 我更新了我的答案. (2认同)