1
0
mirror of https://github.com/silenceper/wechat.git synced 2026-02-04 12:52:27 +08:00
Files
wechat/credential/access_token.go
mqf20 92bf6c7699 use context when getting access token (#815)
* use context

Signed-off-by: mqf20 <mingqingfoo@gmail.com>

* added docs

Signed-off-by: mqf20 <mingqingfoo@gmail.com>

* improved docs

Signed-off-by: mqf20 <mingqingfoo@gmail.com>

* added SetAccessTokenContextHandle

Signed-off-by: mqf20 <mingqingfoo@gmail.com>

---------

Signed-off-by: mqf20 <mingqingfoo@gmail.com>
2025-01-07 22:13:03 +08:00

25 lines
744 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package credential
import "context"
// AccessTokenHandle AccessToken 接口
type AccessTokenHandle interface {
GetAccessToken() (accessToken string, err error)
}
// AccessTokenCompatibleHandle 同时实现 AccessTokenHandle 和 AccessTokenContextHandle
type AccessTokenCompatibleHandle struct {
AccessTokenHandle
}
// GetAccessTokenContext 获取access_token,先从cache中获取没有则从服务端获取
func (c AccessTokenCompatibleHandle) GetAccessTokenContext(_ context.Context) (accessToken string, err error) {
return c.GetAccessToken()
}
// AccessTokenContextHandle AccessToken 接口
type AccessTokenContextHandle interface {
AccessTokenHandle
GetAccessTokenContext(ctx context.Context) (accessToken string, err error)
}