credential

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// CacheKeyOfficialAccountPrefix 微信公众号cache key前缀
	CacheKeyOfficialAccountPrefix = "gowechat_officialaccount_"
	// CacheKeyMiniProgramPrefix 小程序cache key前缀
	CacheKeyMiniProgramPrefix = "gowechat_miniprogram_"
	// CacheKeyWorkPrefix 企业微信cache key前缀
	CacheKeyWorkPrefix = "gowechat_work_"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessTokenContextHandle added in v0.2.3

type AccessTokenContextHandle interface {
	AccessTokenHandle
	GetAccessTokenContext(ctx context.Context) (accessToken string, err error)
}

AccessTokenContextHandle AccessToken 接口

func NewStableAccessToken added in v0.2.3

func NewStableAccessToken(appID, appSecret, cacheKeyPrefix string, cache cache.ICache) AccessTokenContextHandle

NewStableAccessToken new StableAccessToken

type AccessTokenHandle

type AccessTokenHandle interface {
	GetAccessToken(ctx context.Context) (accessToken string, err error)
}

AccessTokenHandle AccessToken 接口

func NewDefaultAccessToken

func NewDefaultAccessToken(appID, appSecret, cacheKeyPrefix string, cache cache.ICache) AccessTokenHandle

NewDefaultAccessToken new DefaultAccessToken

func NewWorkAccessToken

func NewWorkAccessToken(corpID, corpSecret, cacheKeyPrefix string, cache cache.ICache) AccessTokenHandle

NewWorkAccessToken new WorkAccessToken

type DefaultAccessToken

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

DefaultAccessToken 默认AccessToken 获取

func (*DefaultAccessToken) GetAccessToken

func (ak *DefaultAccessToken) GetAccessToken(ctx context.Context) (accessToken string, err error)

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

type DefaultJsTicket

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

DefaultJsTicket 默认获取js ticket方法

func (*DefaultJsTicket) GetTicket

func (js *DefaultJsTicket) GetTicket(ctx context.Context, accessToken string) (ticketStr string, err error)

GetTicket 获取jsapi_ticket

type JsTicketHandle

type JsTicketHandle interface {
	//GetTicket 获取ticket
	GetTicket(ctx context.Context, accessToken string) (ticket string, err error)
}

JsTicketHandle js ticket获取

func NewDefaultJsTicket

func NewDefaultJsTicket(appID string, cacheKeyPrefix string, cache cache.ICache) JsTicketHandle

NewDefaultJsTicket new

type ResAccessToken

type ResAccessToken struct {
	util.CommonError

	AccessToken string `json:"access_token"`
	ExpiresIn   int64  `json:"expires_in"`
}

ResAccessToken struct

func GetTokenFromServerContext added in v0.2.3

func GetTokenFromServerContext(ctx context.Context, url string) (resAccessToken ResAccessToken, err error)

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

type ResTicket

type ResTicket struct {
	util.CommonError

	Ticket    string `json:"ticket"`
	ExpiresIn int64  `json:"expires_in"`
}

ResTicket 请求jsapi_tikcet返回结果

func GetTicketFromServer

func GetTicketFromServer(accessToken string) (ticket ResTicket, err error)

GetTicketFromServer 从服务器中获取ticket

type StableAccessToken added in v0.2.3

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

StableAccessToken 获取稳定版接口调用凭据(与getAccessToken获取的调用凭证完全隔离,互不影响) 不强制更新access_token,可用于不同环境不同服务而不需要分布式锁以及公用缓存,避免access_token争抢 https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-access-token/getStableAccessToken.html

func (*StableAccessToken) GetAccessToken added in v0.2.3

func (ak *StableAccessToken) GetAccessToken(ctx context.Context) (accessToken string, err error)

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

func (*StableAccessToken) GetAccessTokenContext added in v0.2.3

func (ak *StableAccessToken) GetAccessTokenContext(ctx context.Context) (accessToken string, err error)

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

func (*StableAccessToken) GetAccessTokenDirectly added in v0.2.3

func (ak *StableAccessToken) GetAccessTokenDirectly(ctx context.Context, forceRefresh bool) (resAccessToken ResAccessToken, err error)

GetAccessTokenDirectly 从微信获取access_token

type WorkAccessToken

type WorkAccessToken struct {
	CorpID     string
	CorpSecret string
	// contains filtered or unexported fields
}

WorkAccessToken 企业微信AccessToken 获取

func (*WorkAccessToken) GetAccessToken

func (ak *WorkAccessToken) GetAccessToken(ctx context.Context) (accessToken string, err error)

GetAccessToken 企业微信获取access_token,先从cache中获取,没有则从服务端获取

Jump to

Keyboard shortcuts

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