mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-04 12:52:27 +08:00
* 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>
25 lines
744 B
Go
25 lines
744 B
Go
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)
|
||
}
|