wechat_oauth2

package
v0.0.0-...-d36ff20 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponseError

func CheckResponseError(action string, res *http.Response, val interface{}) error

Types

type AccessTokenResponse

type AccessTokenResponse struct {
	AccessToken  string  `json:"access_token"`
	ExpiresIn    uint64  `json:"expires_in"`
	RefreshToken string  `json:"refresh_token"`
	OpenID       string  `json:"openid"`
	Scope        string  `json:"scope"`
	UnionID      *string `json:"unionid"`
}

type Config

type Config struct {
	AppID       string `toml:"app-id"`
	AppSecret   string `toml:"app-secret"`
	RedirectURI string `toml:"redirect-uri"`
}

https://developers.weixin.qq.com/doc/oplatform/en/Website_App/WeChat_Login/Wechat_Login.html

func (*Config) AccessToken

func (p *Config) AccessToken(code string) (*AccessTokenResponse, error)

func (*Config) QrConnectURL

func (p *Config) QrConnectURL(state string, lang string) string

func (*Config) RefreshToken

func (p *Config) RefreshToken(refresh_token string) (*RefreshTokenResponse, error)

type ErrorResponse

type ErrorResponse struct {
	Code    int    `json:"errcode"`
	Message string `json:"errmsg"`
}

type RefreshTokenResponse

type RefreshTokenResponse struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    uint64 `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	OpenID       string `json:"openid"`
	Scope        string `json:"scope"`
}

type UserInfoResponse

type UserInfoResponse struct {
	OpenID     string   `json:"openid"`
	Nickname   string   `json:"nickname"`
	Sex        uint32   `json:"sex"`
	Province   string   `json:"province"`
	City       string   `json:"city"`
	Country    string   `json:"country"`
	HeadImgURL *string  `json:"headimgurl,omitempty"`
	Privilege  []string `json:"privilege"`
	UnionID    string   `json:"unionid"`
}

Jump to

Keyboard shortcuts

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