Skip to content

Commit

Permalink
修改 自定义token获取方法
Browse files Browse the repository at this point in the history
  • Loading branch information
kingway126 committed Aug 3, 2022
1 parent 8e16a7b commit e295625
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions weapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type Client struct {
}

// 用户自定义获取access_token的方法
type AccessTokenGetter func() (token string, expireIn uint)
type AccessTokenGetter func(appid, secret string) (token string, expireIn uint)

// 初始化客户端并用自定义配置替换默认配置
func NewClient(appid, secret string, opts ...func(*Client)) *Client {
Expand Down Expand Up @@ -147,7 +147,7 @@ func (cli *Client) AccessToken() (string, error) {
}

if cli.accessTokenGetter != nil {
token, expireIn := cli.accessTokenGetter()
token, expireIn := cli.accessTokenGetter(cli.appid, cli.secret)
cli.cache.Set(key, token, time.Duration(expireIn)*time.Second)
return token, nil
} else {
Expand Down

0 comments on commit e295625

Please sign in to comment.