python - Google App Engine 远程 API + OAuth

标签 python google-app-engine oauth-2.0 google-oauth

我正在使用 GAE 远程 API 访问我的应用程序的数据存储。使用 remote_api_stub.ConfigureRemoteApi 和返回用户名和密码的身份验证函数对 GAE 进行身份验证。

有没有办法使用 access_token 进行身份验证,例如 OAuth 或 OAuth 2.0?

最佳答案

有一个针对配置为使用两步验证的 Google 帐户的解决方案。

此时,您可能会看到抛出“BadAuthentication InvalidSecondFactor”错误,因为您无法从 shell 正确登录。

为了解决这个问题,你需要一个 App Password授权该应用程序访问您的帐户资源。遵循教程并使用生成的密码和目标 App Engine 应用程序管理员的用户名作为 Remote API 的凭据。

更新:

此外,您可以查看 remote_api_stub.py来自 AppEngine SDK 的文件。您会发现一系列名为 _ConfigureRemoteApiWith* 的方法(请注意前导下划线),例如:

  • _ConfigureRemoteApiWithKeyFile
  • _ConfigureRemoteApiWithComputeEngineCredential
  • _ConfigureRemoteApiWithOAuthCredentials

方法本身有详细的文档,请查看它们的文档字符串。它们会让您使用比 remote_api_stub.ConfigureRemoteApi() 提供的通常 ASP 更安全的方法进行身份验证。

关于python - Google App Engine 远程 API + OAuth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17857138/

相关文章:

ruby-on-rails - EmberJS、Rail 和第三方 OAuth2 登录

python - 使用 pytables 构建一个巨大的 numpy 数组

python - 有时在新的 oAuth 握手后从 intuit anywhere api 获取 "API requires authorization"

python - 是否可以使用 Google App Engine(不带 Google Compute Engine)通过 API 调用(使用 Python)将文件下载到 Google Cloud Storage

python - 在 GQL (Google App Engine) 上获取 4 个不重复的最新结果

asp.net-mvc - OAuth 2 Owin 不工作 StackExchange.Redis SessionState

asp.net-core - .AddOAuth() 与 .AddOpenIdConnect()

python - Pandas 数据框计算

python - 为什么这个 python "War"纸牌游戏只玩了几局就卡住了?

google-app-engine - 我可以通过queue.yaml配置延迟包使用的Task Queue吗?