Documentation ¶
Index ¶
- Variables
- func AuthCodeURL(c *oauth2.Config, state string, opts ...toauth2.AuthCodeOption) string
- func Exchange(ctx context.Context, c *oauth2.Config, code string, ...) (*oauth2.Token, error)
- func GetOpenID(_ context.Context, token *oauth2.Token) (string, error)
- func GetUnionID(_ context.Context, token *oauth2.Token) (string, error)
- func GetUserID(_ context.Context, token *oauth2.Token) (toauth2.UserID, error)
- func RefreshToken(ctx context.Context, c *oauth2.Config, refreshToken string) (*oauth2.Token, error)
- type Provider
- func (p *Provider) AuthCodeURLOptions(options ...toauth2.AuthCodeOption)
- func (p *Provider) BeginAuth(state string) (goth.Session, error)
- func (p *Provider) Client() *http.Client
- func (p *Provider) Debug(debug bool)
- func (p *Provider) ExchangeOptions(options ...toauth2.AuthCodeOption)
- func (p *Provider) FetchUser(session goth.Session) (goth.User, error)
- func (p *Provider) Name() string
- func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error)
- func (p *Provider) RefreshTokenAvailable() bool
- func (p *Provider) SetName(name string)
- func (p *Provider) UnmarshalSession(data string) (goth.Session, error)
- func (p *Provider) UserInfoOptions(options ...toauth2.AuthCodeOption)
- type Session
- type User
Constants ¶
This section is empty.
Variables ¶
var ( AuthURL = "https://open.weixin.qq.com/connect/qrconnect" TokenURL = "https://api.weixin.qq.com/sns/oauth2/access_token" RefreshURL = "https://api.weixin.qq.com/sns/oauth2/refresh_token" UserInfoURL = "https://api.weixin.qq.com/sns/userinfo" )
var ( OptionStyleWhite toauth2.AuthCodeOption = toauth2.SetAuthURLParam("style", "white") OptionStyleBlack toauth2.AuthCodeOption = toauth2.SetAuthURLParam("style", "black") OptionEmptyStyleType toauth2.AuthCodeOption = toauth2.SetAuthURLParam("styletype", "") OptionEmptySizeType toauth2.AuthCodeOption = toauth2.SetAuthURLParam("sizetype", "") )
Functions ¶
func AuthCodeURL ¶
func GetUnionID ¶ added in v0.2.0
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 Wechat.
func New ¶ added in v0.1.5
New creates a new Wechat provider and sets up important connection details. You should always call `wechat.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, refreshURL, 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) ExchangeOptions ¶ added in v0.1.5
func (p *Provider) ExchangeOptions(options ...toauth2.AuthCodeOption)
func (*Provider) FetchUser ¶ added in v0.1.5
FetchUser will go to Wechat and access basic information about the user.
func (*Provider) RefreshToken ¶ added in v0.1.5
RefreshToken get new access token based on the refresh token
func (*Provider) RefreshTokenAvailable ¶ added in v0.1.5
RefreshTokenAvailable refresh token is provided by auth provider or not
func (*Provider) SetName ¶ added in v0.1.5
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
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 }
func (*Session) Authorize ¶ added in v0.1.5
Authorize the session with Wechat and return the access token to be stored for future use.
func (Session) GetAuthURL ¶ added in v0.1.5
GetAuthURL will return the URL set by calling the `BeginAuth` function on the Wechat provider.