Skip to content

Commit

Permalink
Update oauth.md (#2790)
Browse files Browse the repository at this point in the history
Scope considerations
  • Loading branch information
iluyuns authored Feb 21, 2024
1 parent 1a6d898 commit 6554500
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions docs/src/5.x/official-account/oauth.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,11 @@ $config = [

$app = Factory::officialAccount($config);
$oauth = $app->oauth;

// 获取 OAuth 授权结果用户信息
$code = "微信回调URL携带的 code";
$user = $oauth->userFromCode($code);
// 不少用户这里的 code 是来源于静默授权 如果这里你的 $oauth 没有配置 scopes 为 snsapi_base 调用 $oauth->userFromCode($code); 默认会走 snsapi_userinfo;
$oauth = $app->oauth->scopes(['snsapi_base'])
$user = $oauth->userFromCode($code);

$_SESSION['wechat_user'] = $user->toArray();

Expand Down

0 comments on commit 6554500

Please sign in to comment.