【问题标题】:Using OAuth 2.0 (Authentication) token on GAE client在 GAE 客户端上使用 OAuth 2.0(身份验证)令牌
【发布时间】:2014-06-26 02:17:03
【问题描述】:

我正在寻找为我的客户 [web-java 脚本/mob-android 应用程序] 提供安全性的最佳方式,以便授权用户/机器只能访问我的应用程序。在 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 个令牌或为我的 google 账号(我用来创建控制台项目的账号)我可以生成25个token?

[5] 同一个令牌可以用于多个 Web 客户端用户吗?

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

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

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

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

提前致谢

【问题讨论】:

    标签: java android google-app-engine oauth


    【解决方案1】:

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

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

    1. 是的!
    2. 在 cookie 中。为了保护您的用户,我建议使用 Cloudflare pro 获取带有您的域名的 https url。与购买证书相比,成本非常低,并且您有更多的服务来加速您的申请。
    3. 在python中你可以定义生命周期,在JAVA中我想是一样的。
    4. 令牌在整个生命周期和特定域中都有效。
    5. 参见第 4 点。您可以请求更新令牌。
    6. 我不知道。用 Playground 工具测试一下。
    7. 我不明白你的问题。如果您的应用需要向提供者请求数据并且令牌已过期,您需要使用刷新密钥来请求新令牌。

    有关 Python 以外的信息,我邀请您查看此库:https://github.com/scotch/engineauth

    【讨论】:

      猜你喜欢
      • 2015-11-03
      • 1970-01-01
      • 2014-12-24
      • 2015-01-06
      • 1970-01-01
      • 2013-06-21
      • 1970-01-01
      • 2021-08-11
      • 1970-01-01
      相关资源
      最近更新 更多