Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

获取access_token过期之后不自动刷新 #475

Open
RJustice opened this issue Jun 25, 2023 · 1 comment
Open

获取access_token过期之后不自动刷新 #475

RJustice opened this issue Jun 25, 2023 · 1 comment

Comments

@RJustice
Copy link

laravel-wechat 版本: 7.2
Laravel版本: 10
Laravel设置缓存derive : redis

正常清除缓存之后可以正常访问, 查看缓存过期时间1500. 使用配置:

$config = [
            'app_id' => "xxxx",
            'secret' => "xxxx",
            'http' => [
                'timeout' => 5.0,
                'retry' => true,
            ],
        ];

        $app = EasyWeChat::officialAccount()
                         ->setConfig(new Config($config));

        $api = $app->getClient();

设置 use_stable_access_tokenfalse,

当第一次请求之后, 经过缓存时间过期之后就出现了 access_token 过期, 未自动刷新

 {
    "errcode": 40001,
     "errmsg": "invalid credential, access_token is invalid or not latest, could get access_token by getStableAccessToken, more details at https://mmbizurl.cn/s/JtxxFh33r rid: 6497fc3d-2a485f40-20e51066"
}

是否需要自动判断出现 40001 错误码, 使用 $app->getAccessToken()->refresh() , 或者改用 use_stable_access_token

@LixHu
Copy link

LixHu commented Jul 19, 2023

同样遇到了,报错之后进行刷新又获取了一次,才有效

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants