Skip to content

Commit

Permalink
Merge pull request #84 from kingway126/master
Browse files Browse the repository at this point in the history
修改 自定义token获取方法
  • Loading branch information
royalrick authored Aug 7, 2022
2 parents 8e16a7b + e295625 commit 0babb7a
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 0babb7a

Please sign in to comment.