gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 21:01:56 25 4
gpt4 key购买 nike

我正在尝试将 Google Federated Login 与高级应用程序帐户集成,但我遇到了一些问题。

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

但是,使用该 URL(此处称为 端点)并不能使用户保持登录到他们托管的应用程序(gmail、日历、) ,这是一个问题。

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

对端点 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初始请求设置成功)

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

最佳答案

为了记录、子孙后代和任何可能对此产生分歧的人,我将记录(荒谬的)答案。

最终,问题在于调用:

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

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

关于python - 托管应用程序的 Google 联合登录 (OpenID+Oauth) - 更改端点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1543123/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com