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.

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

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!