在GAE客户端上使用OAuth 2.0(身份验证)令牌

时间:2014-05-08 15:23:34

标签: java android google-app-engine oauth

我正在寻找为我的客户提供安全性的最佳方式[web-java script / mob-android app],以便授权用户/机器只能访问我的应用程序。在Google上搜索时,我发现要获得授权,我可以使用Google提供的OAuth 2.0,

[1]建议使用OAuth 2.0吗?

在OAuth 2.0中,首先我们必须使用google console为客户端创建令牌,并且可以在java脚本客户端give here中使用该客户端ID

[2]在web客户端上存储令牌?

在他们提供的developer site

You should write your code to anticipate the possibility that a granted token might no longer work. A token might stop working for one of these reasons:

The user has revoked access.
The token has not been used for six months.
The user account has exceeded a certain number of token requests.
There is currently a 25-token limit per Google user account. If a user account has 25 valid tokens, the next authentication request succeeds, but quietly invalidates the oldest outstanding token without any user-visible warning.

If you need to authorize multiple programs, machines, or devices, one workaround is to limit the  number of clients that you authorize per user account to 15 or 20. If you are a Google Apps admin, you can create additional admin users and use them to authorize some of the clients.

使用oAuth2.0我需要goole,facebook帐户或我的自定义域帐户说www.mysite.com/usr1我可以验证吗?

问题

[3]一旦生成令牌,我们可以控制它的生命时间(如何?)或者它只在六个月后过期?

[4]对于每个Google帐户用户,我可以生成25个令牌或谷歌       帐户(我用来创建控制台项目的帐户)我可以生成25个令牌吗?

[5]可以为多个Web客户端用户使用相同的标记吗?

访问令牌的生命周期有限。如果您的应用需要在单个访问令牌的生命周期之后访问Google API,则可以获取刷新令牌。刷新令牌允许您的应用程序获取新的访问令牌。

[6]访问令牌是否与我从控制台生成的相同?

[7]从哪里可以获得A刷新令牌?

任何帮助将不胜感激!!!

提前致谢

1 个答案:

答案 0 :(得分:2)

我使用oauth,oauth2和openid在我的GAE python应用程序上验证我的用户,实现起来并不简单,但对访问者来说非常有用且简单。

首先,您可以使用oauth 2.0游乐场尝试使用oauth:https://developers.google.com/oauthplayground/

  1. YES!
  2. 在饼干中。为了保护您的用户,我建议您使用Cloudflare pro获取包含您域名的https网址。与购买证书相比,成本非常低,而且您有更多服务来加速您的申请。
  3. 在python中你可以定义生命时间,在JAVA中我想是相同的。
  4. 该令牌在终身和特定域中有效。
  5. 请参阅第4点。您可以请求更新令牌。
  6. 我不知道。用Playground工具测试。
  7. 我不明白你的问题。如果您的应用程序需要从提供程序请求数据并且令牌已过期,则需要使用刷新密钥来请求新令牌。
  8. 有关Python的信息,我邀请您查看此库:https://github.com/scotch/engineauth

相关问题