Update dependencies
This commit is contained in:
84
vendor/OAuth/OAuth2/Service/Harvest.php
vendored
84
vendor/OAuth/OAuth2/Service/Harvest.php
vendored
@@ -2,13 +2,14 @@
|
||||
|
||||
namespace OAuth\OAuth2\Service;
|
||||
|
||||
use OAuth\OAuth2\Token\StdOAuth2Token;
|
||||
use OAuth\Common\Http\Exception\TokenResponseException;
|
||||
use OAuth\Common\Http\Uri\Uri;
|
||||
use OAuth\Common\Consumer\CredentialsInterface;
|
||||
use OAuth\Common\Http\Client\ClientInterface;
|
||||
use OAuth\Common\Storage\TokenStorageInterface;
|
||||
use OAuth\Common\Http\Exception\TokenResponseException;
|
||||
use OAuth\Common\Http\Uri\Uri;
|
||||
use OAuth\Common\Http\Uri\UriInterface;
|
||||
use OAuth\Common\Storage\TokenStorageInterface;
|
||||
use OAuth\Common\Token\TokenInterface;
|
||||
use OAuth\OAuth2\Token\StdOAuth2Token;
|
||||
|
||||
class Harvest extends AbstractService
|
||||
{
|
||||
@@ -23,10 +24,34 @@ class Harvest extends AbstractService
|
||||
parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
|
||||
|
||||
if (null === $baseApiUri) {
|
||||
$this->baseApiUri = new Uri('https://api.github.com/');
|
||||
$this->baseApiUri = new Uri('https://api.harvestapp.com/');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAuthorizationUri(array $additionalParameters = array())
|
||||
{
|
||||
$parameters = array_merge(
|
||||
$additionalParameters,
|
||||
array(
|
||||
'client_id' => $this->credentials->getConsumerId(),
|
||||
'redirect_uri' => $this->credentials->getCallbackUrl(),
|
||||
'state' => 'optional-csrf-token',
|
||||
'response_type' => 'code',
|
||||
)
|
||||
);
|
||||
|
||||
// Build the url
|
||||
$url = clone $this->getAuthorizationEndpoint();
|
||||
foreach ($parameters as $key => $val) {
|
||||
$url->addToQuery($key, $val);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -66,7 +91,8 @@ class Harvest extends AbstractService
|
||||
|
||||
$token = new StdOAuth2Token();
|
||||
$token->setAccessToken($data['access_token']);
|
||||
$token->setEndOfLife($data['expires_in']);
|
||||
$token->setLifetime($data['expires_in']);
|
||||
$token->setRefreshToken($data['refresh_token']);
|
||||
|
||||
unset($data['access_token']);
|
||||
|
||||
@@ -75,6 +101,42 @@ class Harvest extends AbstractService
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes an OAuth2 access token.
|
||||
*
|
||||
* @param TokenInterface $token
|
||||
*
|
||||
* @return TokenInterface $token
|
||||
*
|
||||
* @throws MissingRefreshTokenException
|
||||
*/
|
||||
public function refreshAccessToken(TokenInterface $token)
|
||||
{
|
||||
$refreshToken = $token->getRefreshToken();
|
||||
|
||||
if (empty($refreshToken)) {
|
||||
throw new MissingRefreshTokenException();
|
||||
}
|
||||
|
||||
$parameters = array(
|
||||
'grant_type' => 'refresh_token',
|
||||
'type' => 'web_server',
|
||||
'client_id' => $this->credentials->getConsumerId(),
|
||||
'client_secret' => $this->credentials->getConsumerSecret(),
|
||||
'refresh_token' => $refreshToken,
|
||||
);
|
||||
|
||||
$responseBody = $this->httpClient->retrieveResponse(
|
||||
$this->getAccessTokenEndpoint(),
|
||||
$parameters,
|
||||
$this->getExtraOAuthHeaders()
|
||||
);
|
||||
$token = $this->parseAccessTokenResponse($responseBody);
|
||||
$this->storage->storeAccessToken($this->service(), $token);
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -82,4 +144,14 @@ class Harvest extends AbstractService
|
||||
{
|
||||
return array('Accept' => 'application/json');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return any additional headers always needed for this service implementation's API calls.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getExtraApiHeaders()
|
||||
{
|
||||
return array('Accept' => 'application/json');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user