当前仓库属于暂停状态,部分功能使用受限,详情请查阅 仓库状态说明
1 Star 0 Fork 15

skyone / d3auth
暂停

forked from chunshand / d3auth
暂停
 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

d3auth

第三方登录golang版本的简单实现

安装

go get gitee.com/zchunshan/d3auth

GoDoc

emmm

		type Auth_conf struct {
			Appid  string
			Appkey string
			Rurl   string
		}

使用

gitee


	giteeconf := &d3auth.Auth_conf{Appid: "xxx", Appkey: "xxx", Rurl: "http://www.oschina.net/login"}

	giteeAuth := d3auth.NewAuth_gitee(giteeconf)

	fmt.Print(giteeAuth.Get_Rurl("state")) //获取第三方登录地址

	token, err := giteeAuth.Get_Token("3ce778954a27dd95e46e999667353ac4b780d50fa987d8646a534ac820b02c13") //回调页收的code 获取token
	fmt.Print(token, err)                                                                                 
	userinfo, _ := giteeAuth.Get_User_Info(token.Access_Token)                                            //获取用户信息 userinfo 是一个json字符串返回
	fmt.Print(userinfo)

qq

		qqconf := &d3auth.Auth_conf{Appid: "xxx", Appkey: "xxx", Rurl: "http://www.change.tm"}

		qqAuth := d3auth.NewAuth_qq(qqconf)

		fmt.Print(qqAuth.Get_Rurl("state")) //获取第三方登录地址

		token, err := qqAuth.Get_Token("code")  //回调页收的code 获取token


		me, err := qqAuth.Get_Me(token)  //获取第三方id

		Client_ID string `json:"client_id"`
		OpenID    string `json:"openid"`

		userinfo, _ := wbAuth.Get_User_Info(token, me.OpenID)  //获取用户信息 userinfo 是一个json字符串返回

weibo

		wbconf := &d3auth.Auth_conf{Appid: "xxx", Appkey: "xxx", Rurl: "http://www.change.tm"}

		wbAuth := d3auth.NewAuth_wb(wbconf)

		fmt.Print(wbAuth.Get_Rurl("state")) //获取第三方登录地址


		tokenobj, err := wbAuth.Get_Token("code")

		Access_Token string `json:"access_token"`
		Openid       string `json:"uid"`

		userinfo, _ := wbAuth.Get_User_Info(tokenobj.Access_Token, tokenobj.Openid)//获取用户信息 userinfo 是一个json字符串返回

wechat

		wxconf := &d3auth.Auth_conf{Appid: "xxx", Appkey: "xxx", Rurl: "http://www.change.tm"}

		wxAuth := d3auth.NewAuth_wx(wxconf)

		fmt.Print(wxAuth.Get_Rurl("sate") //获取第三方登录地址

		wxres, err := wxAuth.Get_Token("code")

		userinfo, _ := wxAuth.Get_User_Info(wxres.Access_Token, wxres.Openid) //获取用户信息 userinfo 是一个json字符串返回

github

		githubconf := &d3auth.Auth_conf{Appid: "xxx", Appkey: "xxx", Rurl: "http://www.change.tm/D3/d3_code/type/github"}

		githubAuth := d3auth.NewAuth_github(githubconf)

		fmt.Print(githubAuth.Get_Rurl("state"), "\r\n") //获取第三方登录地址

		token, err := githubAuth.Get_Token("6d92d879d8b1a86922a9") //回调页收的code 获取token
		if err != nil {
			fmt.Print(err, "\r\n")
			return
		}

		userinfo, err := githubAuth.Get_User_Info(token) //获取用户信息 userinfo 是一个json字符串返回
		if err != nil {
			fmt.Print(err)
		}

		fmt.Print(userinfo)	

空文件

简介

golang第三方登录 展开 收起
Go
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Go
1
https://gitee.com/sky_one/d3auth.git
git@gitee.com:sky_one/d3auth.git
sky_one
d3auth
d3auth
master

搜索帮助