Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add expires_in to default token callback #1932

Merged
merged 5 commits into from
Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Google/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public function __construct(array $config = array())
$this->setAccessToken(
[
'access_token' => $newAccessToken,
'expires_in' => 3600, // Google default
'created' => time(),
]
);
Expand Down
8 changes: 6 additions & 2 deletions tests/Google/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -702,9 +702,11 @@ public function testTokenCallback()
// set the token callback to the client
$client->setTokenCallback($callback);

// make a silly request to obtain a new token
// make a silly request to obtain a new token (it's ok if it fails)
$http = $client->authorize();
$http->get('https://www.googleapis.com/books/v1/volumes?q=Voltaire');
try {
$http->get('https://www.googleapis.com/books/v1/volumes?q=Voltaire');
} catch (Exception $e) {}
$newToken = $client->getAccessToken();

// go back to the previous cache
Expand Down Expand Up @@ -742,6 +744,8 @@ public function testDefaultTokenCallback()
$accessToken['access_token'],
$newToken['access_token']
);

$this->assertFalse($client->isAccessTokenExpired());
}

public function testExecuteWithFormat()
Expand Down