qq

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AuthURL     = "https://graph.qq.com/oauth2.0/authorize"
	TokenURL    = "https://graph.qq.com/oauth2.0/token"
	OpenIDURL   = "https://graph.qq.com/oauth2.0/me"
	UserInfoURL = "https://graph.qq.com/user/get_user_info"
)

Functions

func AuthCodeURL

func AuthCodeURL(c *oauth2.Config, state string, opts ...toauth2.AuthCodeOption) string

func Exchange

func Exchange(ctx context.Context, c *oauth2.Config, code string, opts ...toauth2.AuthCodeOption) (*oauth2.Token, error)

func GetOpenID

func GetOpenID(ctx context.Context, token *oauth2.Token) (string, error)

func GetUnionID added in v0.2.0

func GetUnionID(ctx context.Context, token *oauth2.Token) (string, error)

func GetUserID added in v0.2.0

func GetUserID(ctx context.Context, token *oauth2.Token) (toauth2.UserID, error)

func RefreshToken added in v0.1.5

func RefreshToken(ctx context.Context, c *oauth2.Config, refreshToken string) (*oauth2.Token, error)

Types

type Provider added in v0.1.5

type Provider struct {
	ClientKey   string
	Secret      string
	CallbackURL string
	HTTPClient  *http.Client
	// contains filtered or unexported fields
}

Provider is the implementation of `goth.Provider` for accessing QQ.

func New added in v0.1.5

func New(clientKey, secret, callbackURL string, scopes ...string) *Provider

New creates a new QQ provider and sets up important connection details. You should always call `qq.New` to get a new provider. Never try to create one manually.

func NewCustomisedURL added in v0.1.5

func NewCustomisedURL(clientKey, secret, callbackURL, authURL, tokenURL, openIDURL, userInfoURL string, scopes ...string) *Provider

NewCustomisedURL is similar to New(...) but can be used to set custom URLs to connect to

func (*Provider) AuthCodeURLOptions added in v0.1.5

func (p *Provider) AuthCodeURLOptions(options ...toauth2.AuthCodeOption)

func (*Provider) BeginAuth added in v0.1.5

func (p *Provider) BeginAuth(state string) (goth.Session, error)

BeginAuth asks QQ for an authentication end-point.

func (*Provider) Client added in v0.1.5

func (p *Provider) Client() *http.Client

func (*Provider) Debug added in v0.1.5

func (p *Provider) Debug(debug bool)

Debug is a no-op for the qq package.

func (*Provider) ExchangeOptions added in v0.1.5

func (p *Provider) ExchangeOptions(options ...toauth2.AuthCodeOption)

func (*Provider) FetchUser added in v0.1.5

func (p *Provider) FetchUser(session goth.Session) (goth.User, error)

FetchUser will go to QQ and access basic information about the user.

func (*Provider) Name added in v0.1.5

func (p *Provider) Name() string

Name is the name used to retrieve this provider later.

func (*Provider) RefreshToken added in v0.1.5

func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error)

RefreshToken get new access token based on the refresh token

func (*Provider) RefreshTokenAvailable added in v0.1.5

func (p *Provider) RefreshTokenAvailable() bool

RefreshTokenAvailable refresh token is provided by auth provider or not

func (*Provider) SetName added in v0.1.5

func (p *Provider) SetName(name string)

SetName is to update the name of the provider (needed in case of multiple providers of 1 type)

func (*Provider) UnmarshalSession added in v0.1.5

func (p *Provider) UnmarshalSession(data string) (goth.Session, error)

UnmarshalSession wil unmarshal a JSON string into a session.

func (*Provider) UserInfoOptions added in v0.1.5

func (p *Provider) UserInfoOptions(options ...toauth2.AuthCodeOption)

type Session added in v0.1.5

type Session struct {
	AuthURL      string
	AccessToken  string
	RefreshToken string
	ExpiresAt    time.Time
	OpenID       string
	UnionID      string
}

func (*Session) Authorize added in v0.1.5

func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error)

Authorize the session with Wechat and return the access token to be stored for future use.

func (Session) GetAuthURL added in v0.1.5

func (s Session) GetAuthURL() (string, error)

GetAuthURL will return the URL set by calling the `BeginAuth` function on the Wechat provider.

func (Session) Marshal added in v0.1.5

func (s Session) Marshal() string

Marshal the session into a string

func (Session) String added in v0.1.5

func (s Session) String() string

type User

type User struct {
	OpenID       string
	Email        string
	Nickname     string
	FigureURL    string
	FigureURL1   string
	FigureURL2   string
	FigureURLqq1 string
	FigureURLqq2 string
	Gender       string

	Raw map[string]interface{}
}

func GetUser

func GetUser(ctx context.Context, c *oauth2.Config, token *oauth2.Token, opts ...toauth2.AuthCodeOption) (*User, error)

Jump to

Keyboard shortcuts

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