From d1c0fa602607b69f3531b7bd2c9bea6f95ce9227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1si=20Benjamin?= Date: Tue, 26 Feb 2019 10:54:53 +0000 Subject: [PATCH 1/2] Add authParams --- config/users.php | 1 + src/Auth/SocialAuthenticate.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/config/users.php b/config/users.php index 982aab6ad..6d05814da 100644 --- a/config/users.php +++ b/config/users.php @@ -162,6 +162,7 @@ 'providers' => [ 'facebook' => [ 'className' => 'League\OAuth2\Client\Provider\Facebook', + 'authParams' => ['scope' => ['public_profile', 'email', 'user_birthday', 'user_gender', 'user_link']], 'options' => [ 'graphApiVersion' => 'v2.8', //bio field was deprecated on >= v2.8 'redirectUri' => Router::fullBaseUrl() . '/auth/facebook', diff --git a/src/Auth/SocialAuthenticate.php b/src/Auth/SocialAuthenticate.php index a5602c150..ea7050ca6 100755 --- a/src/Auth/SocialAuthenticate.php +++ b/src/Auth/SocialAuthenticate.php @@ -282,7 +282,9 @@ public function unauthenticated(ServerRequest $request, Response $response) $request->getSession()->write('oauth2state', $provider->getState()); } - $response = $response->withLocation($provider->getAuthorizationUrl()); + $authParams = $this->getConfig(sprintf('providers.%s.authParams', $request->getParam('provider'))); + + $response = $response->withLocation($provider->getAuthorizationUrl($authParams)); return $response; } From 21762e8b4ee9ac2bb07be75bbb98155c25a97ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1si=20Benjamin?= Date: Tue, 26 Feb 2019 11:01:37 +0000 Subject: [PATCH 2/2] Add default option --- src/Auth/SocialAuthenticate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Auth/SocialAuthenticate.php b/src/Auth/SocialAuthenticate.php index ea7050ca6..8d99e7f87 100755 --- a/src/Auth/SocialAuthenticate.php +++ b/src/Auth/SocialAuthenticate.php @@ -282,7 +282,7 @@ public function unauthenticated(ServerRequest $request, Response $response) $request->getSession()->write('oauth2state', $provider->getState()); } - $authParams = $this->getConfig(sprintf('providers.%s.authParams', $request->getParam('provider'))); + $authParams = $this->getConfig(sprintf('providers.%s.authParams', $request->getParam('provider')), []); $response = $response->withLocation($provider->getAuthorizationUrl($authParams));