gpt4 book ai didi

google-app-engine - Golang GAE - 联合登录示例

转载 作者:IT王子 更新时间:2023-10-29 00:57:08 25 4
gpt4 key购买 nike

我正在尝试使用 Google App Engine Go SDK 实现联合登录,但我能找到的有关该主题的唯一示例是关于 how to do this in Python and Java 的。 .我知道我需要调用 this function获取 URL,但我不确定要传递的参数。有人可以提供几个主要平台(Facebook、Twitter 等)的 GAE Golang 联合登录示例吗?

最佳答案

Facebook 和 Twitter 不使用 OpenID 进行身份验证。

Facebook 使用 OAuth 2 - 你需要使用 goauth2进行身份验证。

Twitter 使用:OAuth .您需要使用 goauth进行身份验证。

也就是说,如果您仍想为 Yahoo、Google、MySpace 等提供商使用联合登录,它看起来像这样:

c := appengine.NewContext(r)
// url is the OpenID url other possiblities include:
// - yahoo.com
// - myspace.com
// - aol.com
// - flickr.com/USERNAME
url := "gmail.com"
// redirectURL is where you want the User to be redirected to after login.
redirectURL := "/callback"
loginUrl, err := user.LoginURLFederated(c, redirectURL, url)
// Then redirect the user to the url.
http.Redirect(w, r, loginUrl, http.StatusFound)

对于 Facebook 和 Twitter 身份验证,您可以查看 go.auth包裹。它可能不适用于 App Engine,但它可能会为您提供一些线索。

我也在研究 HAL/auth 中这个问题的解决方案包,但截至目前它是不完整的。下面是 HAL 如何处理 app engine openid .

关于google-app-engine - Golang GAE - 联合登录示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11488880/

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