托管应用程序的 Google 联合登录 (OpenID+Oauth) - 更改端点?

Posted

技术标签:

【中文标题】托管应用程序的 Google 联合登录 (OpenID+Oauth) - 更改端点?【英文标题】:Google Federated Login (OpenID+Oauth) for Hosted Apps - changing end points? 【发布时间】:2010-12-05 07:32:15 【问题描述】:

我正在尝试将 Google 联合登录与高级应用帐户集成,但遇到了一些问题。

当我将请求发送到:https://www.google.com/accounts/o8/ud 以及所有参数(见下文)时,我会返回 request_tokenAttribute Exchange 要求的属性列表。这是完美的,因为我们需要通过属性交换 (AX) 的电子邮件将用户存储在我们的应用程序数据库中,并且我们需要未来 API requests to scopes 的请求令牌(即:日历、联系人等)。

但是,使用该 URL(此处称为 endpoint)不会让用户登录到他们托管的应用程序(gmail、日历、),这是一个问题.

将端点更改为https://www.google.com/a/thedomain.com/o8/ud?be=o8 会改变一切。我自动登录到其他谷歌应用程序(gmail 等)。但是,使用该端点,我只能通过 AX 获取请求令牌属性。显然那不是特别混合。它非常相似。

对端点https://www.google.com/accounts/o8/ud的示例请求

parameters = 
    'openid.ns': 'http://specs.openid.net/auth/2.0',
    'openid.claimed_id': 'http://specs.openid.net/auth/2.0/identifier_select',
    'openid.identity': 'http://specs.openid.net/auth/2.0/identifier_select',
    'openid.return_to':'http://our.domain.com/accounts/callback/',
    'openid.realm': 'http://our.domain.com/',
    'openid.assoc_handle': assoc_handle,
    'openid.mode': 'checkid_setup',

    'openid.ns.ext2': 'http://specs.openid.net/extensions/oauth/1.0',
    'openid.ext2.consumer': 'our.domain.com',
    'openid.ext2.scope': 'https://mail.google.com/mail/feed/atom',

    'openid.ns.ax':'http://openid.net/srv/ax/1.0',
    'openid.ax.mode':'fetch_request',
    'openid.ax.required':'firstname,lastname,email',
    'openid.ax.type.firstname':'http://axschema.org/namePerson/first',
    'openid.ax.type.lastname':'http://axschema.org/namePerson/last',
    'openid.ax.type.email':'http://axschema.org/contact/email',     

return HttpResponseRedirect(end_point + '?' + urllib.urlencode(parameters))

(assoc_handle 之前被 openid 初始请求设置成功)

几天来,我一直在努力让这种 Hybird 方法发挥作用,与最不透明的错误消息(This page is invalid ... 感谢 Google)和缺乏一致的文档作斗争。为了达到这一点,我已经搜索了所有代码示例。任何帮助将不胜感激...

【问题讨论】:

【参考方案1】:

为了记录,后人以及任何可能会对此感到困惑的人,我将记录(荒谬的)答案。

最终,问题出在:

return HttpResponseRedirect(
    'https://www.google.com/a/thedomain.com/o8/ud?be=o8'
    + '?'
    + urllib.urlencode(parameters)
)

你能认出来吗?是的,正是问号的明确包含导致了问题。两个查询字符串永远不会同时存在。

【讨论】:

以上是关于托管应用程序的 Google 联合登录 (OpenID+Oauth) - 更改端点?的主要内容,如果未能解决你的问题,请参考以下文章

Google OpenID/联合登录定期失败

联合 google 登录问题(aws 放大和反应原生)

如何使用 AWS Cognito 联合身份进行 Instagram 登录

如何使用联合到 Google 的 Cognito 用户池映射电话号码

微信联合腾讯云打造的云原生新能力来了!

无法登录到Google云平台中托管的3个节点的Cassandra集群中的cqlsh