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

PC端扫描登录的问题 #930

Closed
crisslin opened this issue Sep 19, 2017 · 5 comments
Closed

PC端扫描登录的问题 #930

crisslin opened this issue Sep 19, 2017 · 5 comments

Comments

@crisslin
Copy link

我用的环境

PHP 版本:7.1
overtrue/wechat 版本:最新
是否使用了框架?框架名称:laravel

问题及现象

使用easywechat实现PC端扫描微信登录,使用中间件'wechat.oauth:snsapi_login',显示appid不正确,因为easywechat 默认读取 wechat.php配置文件中appid的值,而不去读取open_platform配置项的值,按道理来说,scope就限定了读取不同的配置方案。
snsapi_login 应该读取第三方平台的值
snsapi_userinfo和snsapi_base 应该读取微信公众号的appid等值


路由中使用中间件
代码:
//pc端微信扫码登录
Route::group(['middleware' => ['web', 'wechat.oauth:snsapi_login']], function () {}

//微信端登录
Route::group(['middleware' => ['web', 'wechat.oauth:snsapi_userinfo']], function () {}

=================================

wechat.php配置文件
/*
* 账号基本信息,请从微信公众平台/开放平台获取
/
'app_id' => env('WECHAT_APPID', '已填'), // AppID
'secret' => env('WECHAT_SECRET', '已填
*'), // AppSecret
'token' => env('WECHAT_TOKEN', 'your-token'), // Token
'aes_key' => env('WECHAT_AES_KEY', ''), // EncodingAESKey

/**
 * 开放平台第三方平台配置信息
 */
 'open_platform' => [
     'app_id'  => env('WECHAT_OPEN_PLATFORM_APPID', '****已填**'),
     'secret'  => env('WECHAT_OPEN_PLATFORM_SECRET', '*****已填*****'),
     'token'   => env('WECHAT_OPEN_PLATFORM_TOKEN', ''),
     'aes_key' => env('WECHAT_OPEN_PLATFORM_AES_KEY', ''),
 ],

//由于值做登录验证,所以token与aes_key 未配置

@crisslin
Copy link
Author

//由于目前只做登录验证,所以token与aes_key 未配置

@mingyoung
Copy link
Collaborator

mingyoung commented Sep 19, 2017 via email

@mingyoung
Copy link
Collaborator

你要用 PC 扫码登录的直接用 overtrue/socialite 即可

@crisslin
Copy link
Author

如果使用中间件模式
//pc端微信扫码登录
Route::group(['middleware' => ['web', 'wechat.oauth:snsapi_login']], function () {}

//微信端登录
Route::group(['middleware' => ['web', 'wechat.oauth:snsapi_userinfo']], function () {}

怎么修改配置项呢

@overtrue
Copy link
Collaborator

@crisslin 这个 wechat.oauth 中间件不支持 PC 开放平台登录

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

3 participants