miniwx

package
v1.12.5 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTokenFromServer

func GetTokenFromServer(url string, respPtr interface{}) (err error)

GetTokenFromServer 强制从微信服务器获取token

Types

type BaseHandler

type BaseHandler struct {
	// contains filtered or unexported fields
}

type CommonError

type CommonError struct {
	ErrCode int64  `json:"errcode"`
	ErrMsg  string `json:"errmsg"`
}

type MiniAccessToken

type MiniAccessToken struct {
	// contains filtered or unexported fields
}

func (*MiniAccessToken) AuthorizeCode

func (ak *MiniAccessToken) AuthorizeCode(code string) (accessToken WxMiniLoginResp, err error)

AuthorizeCode 获取access_token,先从cache中获取,没有则从服务端获取

func (*MiniAccessToken) Credentials

func (ak *MiniAccessToken) Credentials() (accessToken string, err error)

type Oauth2Handle

type Oauth2Handle interface {
	// Credentials 直接换取accessToken(服务器对服务器应用)
	Credentials() (accessToken string, err error)
	// AuthorizeCode 微信登录
	AuthorizeCode(code string) (accessToken WxMiniLoginResp, err error)
}

func New

func New(opts ...Option) Oauth2Handle

type Option

type Option func(handler *BaseHandler)

func WithAuth

func WithAuth(appID string, appSecret string) Option

func WithCache

func WithCache(c cache.C) Option

type ResAccessToken

type ResAccessToken struct {
	CommonError
	AccessToken string `json:"access_token"`
	ExpiresIn   int64  `json:"expires_in"`
}

ResAccessToken struct

type WxMiniLoginResp

type WxMiniLoginResp struct {
	SessionKey string `json:"session_Key,omitempty"`
	UnionId    string `json:"unionid,omitempty"`
	OpenId     string `json:"openid,omitempty"`
	CommonError
}

Jump to

Keyboard shortcuts

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