Issue
I upgraded CakePHP to v4 and with that auth plugin gets upgraded too to version 3.1.
Is there a way to add User-Agent to the github login configuration?
After upgrade I get this error when trying to login:
2020-02-23 01:54:24 Error: [SocialConnect\Provider\Exception\InvalidResponse] API response with error code
Request URL: /social-auth/callback/github?code=c06d043cc8ea5fcd53b4&state=cb84af630eefaf5fe23e6e503df08efd
Referer URL: http://localhost:8765/
Provider Response: Request forbidden by administrative rules. Please make sure your request has a User-Agent header (http://developer.github.com/v3/#user-agent-required). Check https://developer.github.com for other possible causes.
Stack Trace:
#0 .../vendor/socialconnect/auth/src/Provider/AbstractBaseProvider.php(296): SocialConnect\Provider\AbstractBaseProvider->executeRequest(Object(Zend\Diactoros\Request))
#1 .../vendor/socialconnect/auth/src/OAuth2/Provider/GitHub.php(78): SocialConnect\Provider\AbstractBaseProvider->request('GET', 'user', Array, Object(SocialConnect\OAuth2\AccessToken))
#2 .../vendor/admad/cakephp-social-auth/src/Middleware/SocialAuthMiddleware.php(275): SocialConnect\OAuth2\Provider\GitHub->getIdentity(Object(SocialConnect\OAuth2\AccessToken))
#3 .../vendor/admad/cakephp-social-auth/src/Middleware/SocialAuthMiddleware.php(216): ADmad\SocialAuth\Middleware\SocialAuthMiddleware->_getProfile('github', Object(Cake\Http\ServerRequest))
#4 .../vendor/admad/cakephp-social-auth/src/Middleware/SocialAuthMiddleware.php(178): ADmad\SocialAuth\Middleware\SocialAuthMiddleware->_handleCallbackAction(Object(Cake\Http\ServerRequest))
#5 .../vendor/cakephp/cakephp/src/Http/Runner.php(73): ADmad\SocialAuth\Middleware\SocialAuthMiddleware->process(Object(Cake\Http\ServerRequest), Object(Cake\Http\Runner))
#6 .../vendor/cakephp/cakephp/src/Routing/Middleware/RoutingMiddleware.php(156): Cake\Http\Runner->handle(Object(Cake\Http\ServerRequest))
#7 .../vendor/cakephp/cakephp/src/Http/Runner.php(73): Cake\Routing\Middleware\RoutingMiddleware->process(Object(Cake\Http\ServerRequest), Object(Cake\Http\Runner))
#8 .../vendor/cakephp/cakephp/src/Routing/Middleware/AssetMiddleware.php(68): Cake\Http\Runner->handle(Object(Cake\Http\ServerRequest))
#9 .../vendor/cakephp/cakephp/src/Http/Runner.php(73): Cake\Routing\Middleware\AssetMiddleware->process(Object(Cake\Http\ServerRequest), Object(Cake\Http\Runner))
#10 .../vendor/cakephp/cakephp/src/Error/Middleware/ErrorHandlerMiddleware.php(118): Cake\Http\Runner->handle(Object(Cake\Http\ServerRequest))
#11 .../vendor/cakephp/cakephp/src/Http/Runner.php(73): Cake\Error\Middleware\ErrorHandlerMiddleware->process(Object(Cake\Http\ServerRequest), Object(Cake\Http\Runner))
#12 .../vendor/cakephp/debug_kit/src/Middleware/DebugKitMiddleware.php(60): Cake\Http\Runner->handle(Object(Cake\Http\ServerRequest))
#13 .../vendor/cakephp/cakephp/src/Http/Runner.php(73): DebugKit\Middleware\DebugKitMiddleware->process(Object(Cake\Http\ServerRequest), Object(Cake\Http\Runner))
#14 .../vendor/cakephp/cakephp/src/Http/Runner.php(58): Cake\Http\Runner->handle(Object(Cake\Http\ServerRequest))
#15 .../vendor/cakephp/cakephp/src/Http/Server.php(90): Cake\Http\Runner->run(Object(Cake\Http\MiddlewareQueue), Object(Cake\Http\ServerRequest), Object(App\Application))
#16 .../webroot/index.php(40): Cake\Http\Server->run()
#17 {main}
On old CakePHP version 3.8 auth plugin vas version 1.2 (if i remember correctly) and login was working.
My env
PHP: 7.2.x
Library: 3.1
Provider: github
Provider options:
[
'options' => []
];
Will update some info later when I get to my machine.