From 6e6f1d46dba34804a81afddfe3e5b14c252a035b Mon Sep 17 00:00:00 2001 From: Andu Date: Tue, 20 Jan 2015 12:31:49 +0000 Subject: [PATCH 1/3] Add access_type parameter for Google authorization url --- src/Provider/Google.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Provider/Google.php b/src/Provider/Google.php index dbd982a..76284e0 100644 --- a/src/Provider/Google.php +++ b/src/Provider/Google.php @@ -29,6 +29,18 @@ class Google extends AbstractProvider return $this->hostedDomain; } + public $accessType = ''; + + public function setAccessType($accessType) + { + $this->accessType = $accessType; + } + + public function getAccessType() + { + return $this->accessType; + } + public function urlAuthorize() { return 'https://accounts.google.com/o/oauth2/auth'; @@ -97,6 +109,10 @@ class Google extends AbstractProvider $url .= '&' . $this->httpBuildQuery(['hd' => $this->hostedDomain]); } + if (!empty($this->accessType)) { + $url .= '&' . $this->httpBuildQuery(['access_type'=> $this->accessType]); + } + return $url; } } From 3af07921959f1e317b99104eeff35bc999f7f2d0 Mon Sep 17 00:00:00 2001 From: Andu Date: Tue, 20 Jan 2015 12:35:46 +0000 Subject: [PATCH 2/3] Update Google provider tests --- test/src/Provider/GoogleTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/src/Provider/GoogleTest.php b/test/src/Provider/GoogleTest.php index 235b426..0d12156 100644 --- a/test/src/Provider/GoogleTest.php +++ b/test/src/Provider/GoogleTest.php @@ -15,6 +15,7 @@ class GoogleTest extends \PHPUnit_Framework_TestCase 'clientSecret' => 'mock_secret', 'redirectUri' => 'none', 'hostedDomain' => 'mock_domain', + 'accessType' => 'mock_access_type' ]); } @@ -37,6 +38,7 @@ class GoogleTest extends \PHPUnit_Framework_TestCase $this->assertArrayHasKey('response_type', $query); $this->assertArrayHasKey('approval_prompt', $query); $this->assertArrayHasKey('hd', $query); + $this->assertArrayHasKey('access_type', $query); $this->assertNotNull($this->provider->state); } @@ -107,4 +109,15 @@ class GoogleTest extends \PHPUnit_Framework_TestCase $this->provider->setHostedDomain('changed_domain'); $this->assertEquals('changed_domain', $this->provider->hostedDomain); } + + public function testGetAccessType() + { + $this->assertEquals('mock_access_type', $this->provider->getAccessType()); + } + + public function testSetAccessType() + { + $this->provider->setAccessType('changed_access_type'); + $this->assertEquals('changed_access_type', $this->provider->accessType); + } } From 3afc1f9a053901d42173813095823616c7254554 Mon Sep 17 00:00:00 2001 From: Andu Date: Tue, 20 Jan 2015 12:49:06 +0000 Subject: [PATCH 3/3] Add docblock for the access_type variable in the Google provider --- src/Provider/Google.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Provider/Google.php b/src/Provider/Google.php index 76284e0..1896885 100644 --- a/src/Provider/Google.php +++ b/src/Provider/Google.php @@ -29,6 +29,10 @@ class Google extends AbstractProvider return $this->hostedDomain; } + /** + * @var string If set, this will be sent to google as the "access_type" parameter. + * @link https://developers.google.com/accounts/docs/OAuth2WebServer#offline + */ public $accessType = ''; public function setAccessType($accessType)