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

企业微信授权scopes=snsapi_privateinfo报错agent_id必填,需要额外调用withAgentId,是否可优化呢? #2619

Closed
lyt8384 opened this issue Nov 14, 2022 · 4 comments

Comments

@lyt8384
Copy link
Contributor

lyt8384 commented Nov 14, 2022

我用的环境

  • PHP 版本:8.1
  • overtrue/wechat 版本:6.9.2
  • 是否使用了框架?框架名称:否

问题及现象

伪代码如下

$config = [
    'agent_id' => '1000005'
    'corp_id' => 'xxxxx', //企业ID
    'secret'   => 'xxxxx', // 应用的 secret
];
$app = new EasyWeChat\work\Application($config);
$url = $app->getOAuth()->scopes(['snsapi_privateinfo'])->redirect('CallBack URL');

会报错agent_id is require when qrcode mode or scopes is 'snsapi_privateinfo'
分析代码,在/src/Work/Application.php L143 调用Overtrue\Socialite\Providers\WeWork时未传入agent_id, 但是在overtrue/socialite 那一侧又支持带入agent_id,这里是否可优化呢?

ps.虽然可以在getOAuth()withAgentId($agent_id)去解决这个问题,但是总感觉能配置的不应该再在调用中去带入用。
thx~

@overtrue
Copy link
Collaborator

@jiangslee
Copy link
Contributor

这个agentId是不是过不了phpunit?

Script phpstan analyse --memory-limit=-1 handling the phpstan event returned with error code 1
> phpunit --colors
PHPUnit 9.5.26 by Sebastian Bergmann and contributors.

...............................................................  63 / 176 ( 35%)
............................................................... 126 / 176 ( 71%)
................................E.................              176 / 176 (100%)

Time: 00:00.191, Memory: 18.00 MB

There was 1 error:

1) EasyWeChat\Tests\Work\ApplicationTest::test_get_oauth
ReflectionException: Cannot access non-public property Overtrue\Socialite\Providers\WeWork::$agentId

/Users/jiangslee/php/easywechat-git/tests/Work/ApplicationTest.php:270

ERRORS!
Tests: 176, Assertions: 523, Errors: 1.
Script phpunit --colors handling the test event returned with error code 2

@overtrue
Copy link
Collaborator

➜ composer test
> phpunit --colors
PHPUnit 9.5.25 #StandWithUkraine

...............................................................  63 / 176 ( 35%)
............................................................... 126 / 176 ( 71%)
..................................................              176 / 176 (100%)

Time: 00:00.257, Memory: 16.00 MB

OK (176 tests, 526 assertions)

我擦嘞?php 几?

@jiangslee
Copy link
Contributor


➜ composer test

> phpunit --colors

PHPUnit 9.5.25 #StandWithUkraine



...............................................................  63 / 176 ( 35%)

............................................................... 126 / 176 ( 71%)

..................................................              176 / 176 (100%)



Time: 00:00.257, Memory: 16.00 MB



OK (176 tests, 526 assertions)

我擦嘞?php 几?

我好像是8.0.1x,还有fork那的ci php-8-lowest和php-8.1-lowest过不了,https://github.com/jiangslee/easywechat/actions/runs/3501977162

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