Skip to content

Commit

Permalink
Merge 8dd1e49 into 2dfd407
Browse files Browse the repository at this point in the history
  • Loading branch information
guywithnose committed Sep 23, 2014
2 parents 2dfd407 + 8dd1e49 commit 24baea8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public static function createOwnerCredentials(
public static function parseTokenResponse(Response $response)
{
$parsedJson = $response->getResponse();
Util::ensureNot('invalid_client', Arrays::get($parsedJson, 'code'), 'Invalid Credentials');
Util::ensure(200, $response->getHttpCode(), Arrays::get($parsedJson, 'error_description', 'Unknown API error'));
return [$parsedJson['access_token'], Arrays::get($parsedJson, 'refresh_token'), time() + (int)$parsedJson['expires_in']];
}
Expand Down
12 changes: 12 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,18 @@ public function end($handle)
return $response;
}

/**
* Refresh and return valid tokens
*
* @return array two string values, access token and refresh token
*/
public function login()
{
$this->_refreshAccessToken();

return $this->getTokens();
}

private static function _isExpiredToken(Response $response)
{
if ($response->getHttpCode() !== 401) {
Expand Down

0 comments on commit 24baea8

Please sign in to comment.