调试微信授权登录

This commit is contained in:
luofei 2024-03-07 17:41:49 +08:00
parent 891ab45bdf
commit 54bf58b197

View File

@ -874,9 +874,10 @@ class Auth extends BaseController
throw new ValidateException('授权失败[003]');
return $user;
} else if ($auth['type'] === 'app_wechat') {
$oauth = WechatService::create()->getApplication()->oauth;
$oauth = WechatService::create(true)->getApplication()->oauth;
$accessToken = $oauth->getAccessToken($data['code']);
try {
$wechatInfo = $oauth->user(new AccessToken(['access_token' => $data['code'], 'openid' => $data['openid']]))->getOriginal();
$wechatInfo = $oauth->user($accessToken)->getOriginal();
} catch (Exception $e) {
throw new ValidateException('授权失败[001]' . $e->getMessage());
}