-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoauth.go
48 lines (37 loc) · 847 Bytes
/
oauth.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package goauth
import (
"github.com/wenlincheng/goauth/model"
"github.com/wenlincheng/goauth/wechat"
)
type GoAuth struct {
}
// 统一接口
type IOauth interface {
// 设置链接
SetUri(uriType model.OauthUriType, uri string)
// 获取授权链接
GetAuthorizeUrl(args ...string) string
// 获取令牌
GetAccessToken(code string) (*model.OauthToken, error)
// 刷新令牌
RefreshAccessToken(refreshToken string) (*model.OauthToken, error)
// 获取用户信息
GetUserInfo(accessToken, openId string) (*model.OauthUser, error)
}
// 微信
func (g *GoAuth) NewWechat(appid, appSecret string) *wechat.WeChat {
weChat := wechat.WeChat{
AppID: appid,
AppSecret: appSecret,
}
return &weChat
}
// QQ
func (g *GoAuth) NewQQ() {
}
// 微博
func (g *GoAuth) NewWeibo() {
}
// Github
func (g *GoAuth) NewGithub() {
}