diff --git a/src/Client.php b/src/Client.php index 0b44dfae3..cfb59bbb4 100644 --- a/src/Client.php +++ b/src/Client.php @@ -386,6 +386,7 @@ public function createAuthUrl($scope = null) 'login_hint' => $this->config['login_hint'], 'openid.realm' => $this->config['openid.realm'], 'prompt' => $this->config['prompt'], + 'redirect_uri' => $this->config['redirect_uri'], 'response_type' => 'code', 'scope' => $scope, 'state' => $this->config['state'], diff --git a/tests/Google/ClientTest.php b/tests/Google/ClientTest.php index 23eebd562..5046f38bf 100644 --- a/tests/Google/ClientTest.php +++ b/tests/Google/ClientTest.php @@ -1015,4 +1015,20 @@ public function testCredentialsOptionWithCredentialsLoader() $this->assertNotNull($authHeader); $this->assertEquals('Bearer abc', $authHeader); } + + public function testSetNewRedirectUri() + { + $client = new Client(); + $redirectUri1 = 'https://foo.com/test1'; + $client->setRedirectUri($redirectUri1); + + $authUrl1 = $client->createAuthUrl(); + $this->assertStringContainsString(urlencode($redirectUri1), $authUrl1); + + $redirectUri2 = 'https://foo.com/test2'; + $client->setRedirectUri($redirectUri2); + + $authUrl2 = $client->createAuthUrl(); + $this->assertStringContainsString(urlencode($redirectUri2), $authUrl2); + } }