python - 适用于 Google App Engine Python 的 OAuth

标签 python google-app-engine oauth

我一直在这里仔细阅读有关如何为 GAE Python 实现 OAuth 的文档:https://cloud.google.com/appengine/docs/python/oauth/#Python_OAuth_and_App_Engine

以下步骤很有意义。但我不知道如何使所有这些工作。我想要做的就是能够访问 https://www.googleapis.com/oauth2/v1/userinfo 以便用户可以将他/她的电子邮件存储在应用程序的 ndb 中。

第一步:导入oauth

从 google.appengine.api 导入 o​​auth

第二步:获取当前用户

user = oauth.get_current_user()

第三步:获取请求 token https://your_app_id.appspot.com/_ah/OAuthGetRequestToken

第四步:授权token https://your_app_id.appspot.com/_ah/OAuthAuthorizeToken

第 5 步:获取访问 token https://your_app_id.appspot.com/_ah/OAuthGetAccessToken

第 6 步:从 google 获取信息 ' https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=TOKENWOULDGOHERE

我找不到任何可以用来帮助我解决这个问题的好例子。根据我的发现,我似乎总是遇到导入错误或身份验证错误。例如 ImportError:没有名为 oauth2client.client 的模块

如果有人能给我写一个示例或指出正确的方向以使用 GAE Python 从 OAuth2 简单地获取用户的电子邮件地址,我将永远感激不已。非常感谢!

最佳答案

This video真的帮助我让 OAuth 正常工作。使用decorators简化了整个过程。

关于python - 适用于 Google App Engine Python 的 OAuth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27165778/

相关文章:

java - 如何处理 Google App Engine 中的传入请求错误 'Request Too Large'?

OAuth 问题的 PHP Twitter 应用程序

python - 如何从蒙版图像中删除图章/水印?

python - 在 python 中,在 Windows 上,如何等到鼠标移动?

python - 通过 API 连接时,Interactive Broker 中出现错误“错误 id=-1,错误代码=2104,错误消息=市场数据场连接正常 :hfarm”

python - 将 pandas DataFrame 列拆分为可变数量的列

google-app-engine - 我想制作一个 Google App Engine 应用程序;具有良好的 JavaSE/Swing + Javascript/(X)HTML + 关系数据库 (SQL) 背景

java - org.datanucleus.store.query.QueryCompilerSyntaxException : Identifier expected at character 12 in "u.username== value"

web-services - 我可以使用 Facebook OAuth 来保护我的 RESTful Web 服务吗?

ruby - 谷歌的 Omniauth 错误