dqthn68688 2015-11-10 05:30
浏览 91
已采纳

使用OAuth2.0作为Webapp的授权系统

I'm fairly new to implementing an authorization system for webapps and would like to use OAuth2.0 with Google to provide authorization to users that need to login to their accounts on the webapp. This means that Google will be providing the account details for users, but I will not be using the Google API. I will need a way to tell who's logged on and whether they have access to certain APIs using OAuth. I am aware that Google provides simple sign-in, but I would like to learn more about OAuth 2.0, which is why I'm using it.

I've been doing some research to try and understand OAuth2.0 in general (this presentation has been particularly useful). From what I understand there are several different response types for OAuth, but I haven't been able to figure out what suites my use case the best.

Since I'm using Golang for my backend (Gocraft/web for mux and middleware and Golang OAuth2.0 for OAuth2.0, I would appreciate an example related to Golang, if anyone is willing to give me one. I haven't been able to get far, but I've got an OAuth2.0 configuration up:

oauthConfig := &oauth2.Config{
    ClientID: "...",
    ClientSecret: "...",
    Endpoint: oauth2.Endpoint{
        AuthURL: "https://accounts.google.com/o/oauth2/auth",
        TokenURL: "https://accounts.google.com/o/oauth2/token",
    },
    RedirectURL: "...",
    Scopes: []string{ "https://www.googleapis.com/auth/userinfo.profile" },
}

Any insight would be appreciated, thank you!

  • 写回答

1条回答 默认 最新

  • dongnaoxia0927 2015-11-11 00:14
    关注

    I ended up using Goth, as suggested in this comment by @elithrar.

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

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP