d3outh
golang写的简易版第三方登录方法
假如有错误之处 还请直接提出 立马改正
安装
go get github.com/zcshan/d3outh
emmm
Appid appid Appkey secret Rurl 回调地址
使用
qqconf := &d3outh.Outh_conf{Appid: "xxx", Appkey: "xxx", Rurl: "http://www.change.tm"}
qqouth := d3outh.NewOuth_qq(qqconf)
fmt.Print(qqouth.Get_Rurl("state")) //获取第三方登录地址token, err := qqouth.Get_Token("code") //回调页收的code 获取tokenme, err := qqouth.Get_Me(token) //获取第三方idClient_ID string `json:"client_id"`
OpenID string `json:"openid"`
userinfo, _ := wbouth.Get_User_Info(token, me.OpenID) //获取用户信息 userinfo 是一个json字符串返回wbconf := &d3outh.Outh_conf{Appid: "xxx", Appkey: "xxx", Rurl: "http://www.change.tm"}
wbouth := outh.NewOuth_wb(wbconf)
fmt.Print(wbouth.Get_Rurl("state")) //获取第三方登录地址tokenobj, err := wbouth.Get_Token("code")
Access_Token string `json:"access_token"`
Openid string `json:"uid"`
userinfo, _ := wbouth.Get_User_Info(tokenobj.Access_Token, tokenobj.Openid)//获取用户信息 userinfo 是一个json字符串返回wxconf := &d3outh.Outh_conf{Appid: "xxx", Appkey: "xxx", Rurl: "http://www.change.tm"}
wxouth := outh.NewOuth_wx(wxconf)
fmt.Print(wxouth.Get_Rurl("sate")) //获取第三方登录地址wxres, err := wxouth.Get_Token("code")
userinfo, _ := wxouth.Get_User_Info(wxres.Access_Token, wxres.Openid) //获取用户信息 userinfo
作者:ChunShan
链接:https://www.jianshu.com/p/7d46eee7cad4
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦