Skip to content

Commit 1cd8543

Browse files
author
Ian Barber
committed
Ensure that empty array is stripped in getAccessToken
This maintains the previous behaviour where an uninitialised access token would return null.
1 parent e6cd3ac commit 1cd8543

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Google/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public function getAccessToken()
250250
// The response is json encoded, so could be the string null.
251251
// It is arguable whether this check should be here or lower
252252
// in the library.
253-
return (null == $token || 'null' == $token) ? null : $token;
253+
return (null == $token || 'null' == $token || '[]' == $token) ? null : $token;
254254
}
255255

256256
/**

tests/general/ApiClientTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ public function testPrepareInvalidScopes() {
4848
$this->assertEquals("", $scopes);
4949
}
5050

51+
public function testNoAuthIsNull() {
52+
$client = new Google_Client();
53+
54+
$this->assertNull($client->getAccessToken());
55+
}
56+
5157
public function testPrepareService() {
5258
$client = new Google_Client();
5359
$client->setScopes(array("scope1", "scope2"));

0 commit comments

Comments
 (0)