wx

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AccessTokenKey  = "access_token::"
	RefreshTokenKey = "refresh_token::"
	AccessTokenTTL  = 7000
	RefreshTokenTTL = 7000
)
View Source
var (
	WebAccessTokenKey  = "web_access_token::"
	WebAccessTokenTTL  = 7000
	WebRefreshTokenKey = "web_refresh_token::"
	WebRefreshTokenTTL = 3600 * 24 * 29
)

Functions

func GetAccessToken

func GetAccessToken(appId string, secret string, cache *cache.RedisCache) (string, error)

func GetAccessTokenByCache

func GetAccessTokenByCache(appId string, cache *cache.RedisCache) (string, string, error)

func GetAccessTokenByCode

func GetAccessTokenByCode(appId string, secret string, code string, cache *cache.RedisCache) (string, string, error)

func Verify

func Verify(token string, method string, urls []string) gin.HandlerFunc

Types

type AccessToken

type AccessToken struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
}

type TokenVerifyReq

type TokenVerifyReq struct {
	Signature string `json:"signature" form:"signature"`
	Timestamp string `json:"timestamp" form:"timestamp"`
	EchoStr   string `json:"echostr" form:"echostr"`
	Nonce     string `json:"nonce" form:"nonce"`
}

type UserInfo

type UserInfo struct {
	Openid     string   `json:"openid"`
	Nickname   string   `json:"nickname"`
	Sex        int      `json:"sex"`
	Province   string   `json:"province"`
	City       string   `json:"city"`
	Country    string   `json:"country"`
	Headimgurl string   `json:"headimgurl"`
	Privilege  []string `json:"privilege"`
	Unionid    string   `json:"unionid"`
	Errcode    int      `json:"errcode"`
	Errmsg     string   `json:"errmsg"`
}

func GetUserInfo

func GetUserInfo(accessToken string, openId string) (*UserInfo, error)

func GetWebUserInfo

func GetWebUserInfo(token string, openid string) (*UserInfo, error)

type WebAccessToken

type WebAccessToken struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	Openid       string `json:"openid"`
	Scope        string `json:"scope"`
	Unionid      string `json:"unionid"`
	Errcode      int    `json:"errcode"`
	Errmsg       string `json:"errmsg"`
}

Jump to

Keyboard shortcuts

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