social

package
v0.0.0-...-cd24349 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultInvokerCfg = InvokerCfg{
	Debug:     false,
	Mode:      "",
	AppID:     "",
	AppSecret: "",
}

Functions

func DefaultBuild

func DefaultBuild() module.Invoker

default invoker build

Types

type AuthInfo

type AuthInfo struct {
	ClientID string `json:"client_id"`
	OpenID   string `json:"openid"`
	UnionID  string `json:"unionid"`
}

type BasicTokenInfo

type BasicTokenInfo struct {
	AccessToken string
}

type BasicUserInfo

type BasicUserInfo struct {
	NickName string
	HeadIcon string
}

type Client

type Client struct {
	SocialService
	// contains filtered or unexported fields
}

func Invoker

func Invoker(name string) *Client

invoker

type GithubClient

type GithubClient struct {
	AppID       string
	AppSecret   string
	AccessToken string
	OpenID      string
	Name        string
	RedirectURI string
}

func (*GithubClient) GetAccessToken

func (c *GithubClient) GetAccessToken(code string) (*BasicTokenInfo, error)

func (*GithubClient) GetType

func (c *GithubClient) GetType() string

func (*GithubClient) GetUserInfo

func (c *GithubClient) GetUserInfo(accessToken string) (*BasicUserInfo, error)

func (*GithubClient) LoginPage

func (c *GithubClient) LoginPage(state string) string

get login page github state empty string

type InvokerCfg

type InvokerCfg struct {
	Debug       bool
	Mode        string
	AppID       string
	AppSecret   string
	RedirectURI string
}

example * [beemod.oauth2.qq]

debug = true
mode  = "qq"
app_id  = "app_id"
app_secret  = "app_secret"
redirectURI = "www.beego.com"

[beemod.oauth2.wx]

debug = true
mode  = "wx"
app_id  = "app_id"
app_secret  = "app_secret"
redirectURI = "www.beego.com"

[beemod.oauth2.github]

debug = true
mode  = "github"
app_id  = "app_id"
app_secret  = "app_secret"
redirectURI = "www.beego.com"

type QQClient

type QQClient struct {
	AppID       string
	AppKey      string
	RedirectURI string
	Name        string
	OpenID      string
}

func (*QQClient) GetAccessToken

func (c *QQClient) GetAccessToken(code string) (*BasicTokenInfo, error)

get token

func (*QQClient) GetOpenID

func (c *QQClient) GetOpenID(accessToken string) (*AuthInfo, error)

get OpenID

func (*QQClient) GetType

func (c *QQClient) GetType() string

func (*QQClient) GetUserInfo

func (c *QQClient) GetUserInfo(accessToken string) (*BasicUserInfo, error)

get userInfo

func (*QQClient) LoginPage

func (c *QQClient) LoginPage(state string) string

get login page

type QQUserInfo

type QQUserInfo struct {
	Ret             int64  `json:"ret"`                // 返回代码
	Msg             string `json:"msg"`                // 错误信息
	Nickname        string `json:"nickname"`           // QQ空间的昵称
	FigType         string `json:"figureurl_type"`     // 头像类型
	Fig             string `json:"figureurl"`          // 30×30 像素空间头像
	Fig1            string `json:"figureurl_1"`        // 50×50 像素空间头像
	Fig2            string `json:"figureurl_2"`        // 100×100 像素空间头像
	FigQQ           string `json:"figureurl_qq"`       // 640×640 QQ头像
	FigQQ1          string `json:"figureurl_qq_1"`     // 40×40 QQ头像
	FigQQ2          string `json:"figureurl_qq_2"`     // 100×100 QQ头像(可能为空)
	Gender          string `json:"gender"`             // 性别(未设置则返回“男”)
	GenderType      int64  `json:"gender_type"`        // 性别类型
	Province        string `json:"province"`           // 省份
	City            string `json:"city"`               // 城市
	Year            string `json:"year"`               // 出生年份
	Constellation   string `json:"constellation"`      // 星座
	IsYellowVIP     string `json:"is_yellow_vip"`      // 是否为黄钻用户
	IsYellowYearVIP string `json:"is_yellow_year_vip"` // 是否年费黄钻用户
	YellowVIPLevel  string `json:"yellow_vip_level"`   // 黄钻登机
	VIP             string `json:"vip"`                // 是非VIP
	Level           string `json:"level"`              // VIP等级
	IsLost          int64  `json:"is_lost"`            // 未知
}

UserInfo get_user_info api response

type QQ_Error

type QQ_Error struct {
	Error             int    `json:"error"`
	Error_description string `json:"error_description"`
}

type SocialService

type SocialService interface {
	LoginPage(state string) string
	GetAccessToken(code string) (*BasicTokenInfo, error)
	GetUserInfo(accessToken string) (*BasicUserInfo, error)
	GetType() string
}

func NewGithubOauth2Service

func NewGithubOauth2Service(app_id, app_secret, redirectURI string) SocialService

func NewQQauth2Service

func NewQQauth2Service(appID, appKey, redirectURI string) SocialService

func NewWxOauth2Service

func NewWxOauth2Service(app_id, app_secret, redirectURI string) SocialService

type WxClient

type WxClient struct {
	AppID       string
	AppSecret   string
	AccessToken string
	OpenID      string
	Name        string
	RedirectURI string
}

func (*WxClient) GetAccessToken

func (c *WxClient) GetAccessToken(code string) (*BasicTokenInfo, error)

func (*WxClient) GetType

func (c *WxClient) GetType() string

func (*WxClient) GetUserInfo

func (c *WxClient) GetUserInfo(accessToken string) (*BasicUserInfo, error)

func (*WxClient) LoginPage

func (c *WxClient) LoginPage(state string) string

get login page

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL