dowaw80220 2012-07-15 02:18
浏览 67
已采纳

Golang GAE-联合登录示例

I'm trying to implement Federated Login using Google App Engine Go SDK, but the only examples I can find on the subject are about how to do this in Python and Java. I understand that I need to call this function to get the URL, but I'm not sure about the parameters to pass. Can someone provide examples of Federated Login in GAE Golang for a few major platforms (Facebook, Twitter, etc)?

  • 写回答

1条回答 默认 最新

  • douju1852 2012-07-15 15:17
    关注

    Facebook and Twitter don't use OpenID for authentication.

    Facebook uses OAuth 2 - You'll need to use goauth2 to authenticate.

    Twitter uses: OAuth. You'll need to use goauth to authenticate.

    That said if you are still wanting to use Federated Login for providers like Yahoo, Google, MySpace it would look like this:

    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)
    

    For Facebook and Twitter authentication you might look at the go.auth package. It might not work with App Engine but it might give you some clues.

    I'm also working on a solution to this problem in the HAL/auth package, but as of now it's incomplete. Here's how HAL handles app engine openid.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?
  • ¥15 关于#vue.js#的问题:修改用户信息功能图片无法回显,数据库中只存了一张图片(相关搜索:字符串)
  • ¥15 texstudio的问题,
  • ¥15 spaceclaim模型变灰色