Skip to content

Commit

Permalink
Merge pull request #100 from bshaffer/fixes-gce-last-received-token
Browse files Browse the repository at this point in the history
fixes GCE::getLastReceivedToken
  • Loading branch information
bshaffer committed Mar 3, 2016
2 parents c05fe66 + af14396 commit f328886
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Credentials/GCECredentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public function fetchAuthToken(callable $httpHandler = null)

// store this so we can retrieve it later
$this->lastReceivedToken = $json;
$this->lastReceivedToken['expires_at'] = time() + $json['expires_in'];

return $json;
}
Expand All @@ -187,7 +188,7 @@ public function getLastReceivedToken()
if ($this->lastReceivedToken) {
return [
'access_token' => $this->lastReceivedToken['access_token'],
'expires_at' => $this->lastReceivedToken['expiration_time'],
'expires_at' => $this->lastReceivedToken['expires_at'],
];
}

Expand Down
1 change: 1 addition & 0 deletions tests/Credentials/GCECredentialsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,6 @@ public function testShouldReturnTokenInfo()
]);
$g = new GCECredentials();
$this->assertEquals($wantedTokens, $g->fetchAuthToken($httpHandler));
$this->assertEquals(time() + 57, $g->getLastReceivedToken()['expires_at']);
}
}
2 changes: 1 addition & 1 deletion tests/FetchAuthTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private function getGCECredentials()
$credentials = new GCECredentials();
$property->setValue($credentials, [
'access_token' => 'xyz',
'expiration_time' => strtotime('2001'),
'expires_at' => strtotime('2001'),
]);

return $credentials;
Expand Down

0 comments on commit f328886

Please sign in to comment.