From e295625ae7c776ca1b297ff0c225808b77af3b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E9=87=91=E5=A8=81?= <1098977435@qq.com> Date: Wed, 3 Aug 2022 10:59:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89token=E8=8E=B7=E5=8F=96=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- weapp.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/weapp.go b/weapp.go index 3d8396b..d33b3c5 100644 --- a/weapp.go +++ b/weapp.go @@ -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 { @@ -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 {