【问题标题】:Google OAuth 2.0 Request FormatGoogle OAuth 2.0 请求格式
【发布时间】:2015-04-21 15:31:03
【问题描述】:

网络应用程序如何将用户重定向到 Google 进行身份验证,并在 Google 的 OAuth 2.0 端点的 URL 参数中包含签名请求?

例如,如何将以下明文请求转换为签名和加密的请求?

https://accounts.google.com/o/oauth2/auth?client_id=424911365001.apps.googleusercontent.com&response_type=code&scope=openid%20email&redirect_uri=https://oa2cb.example.com/&state=security_token%3D138r5719ru3e1%26url%3Dhttps://oa2cb.example.com/myHome&login_hint=jsmith@example.com&openid.realm=example.com&hd=example.com

【问题讨论】:

    标签: google-api google-oauth


    【解决方案1】:

    您不能重定向 URI 只是将身份验证返回到的页面的位置,即可以处理调用的页面。必须是静态页面,路径。

    在 Google Developer Console 中明确说明

    每行一个 URI。需要有协议,没有 URL 片段,并且没有 相对路径。不能是非私有 IP 地址。

    有效的重定向 URI

    http://localhost/authorize/ 
    http://localhost/google-api-php-client-samples/PlusLogin/index.php 
    http://test.daimto.com/Oauth2.php 
    http://WWW.daimto.com/Oauth2.php 
    

    Oauth2 示例:

    https://accounts.google.com/o/oauth2/auth?client_id={clientid}.apps.googleusercontent.com&redirect_uri=http://localhost/google-api-php-client-samples/Analytics/Oauth2.php &scope=https://www.googleapis.com/auth/analytics.readonly&response_type=code
    

    【讨论】:

    • 我不明白这如何回答关于签署授权请求的问题;这个答案是关于传递授权响应的 URL。
    • 授权响应被传递到重定向 uri。这不是动态的事情。 accounts.google.com/o/oauth2/auth 是他想要获得验证码的第一步。所以这又是我们所说的重定向 uri。
    【解决方案2】:

    目前无法将签名(或加密)身份验证请求发送到 Google 的授权端点,因为 Google 不支持。

    然而,Google 的身份验证协议与 OpenID Connect 兼容,并且该规范具有一个可选功能,允许发送以 JWT 表示的身份验证请求,这些请求可以是签名和/或加密的 JSON 对象。请参阅:http://openid.net/specs/openid-connect-core-1_0.html#RequestObject 将来 Google 可能会开始支持该功能,但目前不支持。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-03
      • 2015-12-09
      • 2015-07-24
      • 2014-08-19
      • 2014-10-05
      • 2012-11-23
      相关资源
      最近更新 更多