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

标签 google-app-engine authentication openid go federated-identity

我正在尝试使用 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/

相关文章:

asp.net-mvc - 用于 OpenID + OAuth + 普通身份验证的 ASP.NET MVC 解决方案

openid - 我可以通过标准 Google 帐户使用 OpenID 委托(delegate)吗?

openid - 对您的网站使用OpenID有哪些危险?

javascript - 无法从 Chrome 扩展访问端点 API

java - 尝试执行 Blob 存储并将表单数据添加到数据存储 预检错误

python - dev_appserver.py 给我一个错误

django Restframework token 身份验证失败,错误代码为 "invalid token"

java - 覆盖 Google App Engine 中的数据存储区实体 - Java

PHP 如果逻辑被跳过?

node.js - 在 NodeJS 后端使用 JWT 和 Active Directory 身份验证