OAuthOAuth2ServiceHarvest

The Gravity Forms Salesforce Add-On OAuth OAuth2 Service Harvest class.

Defined (1)

The class is defined in the following location(s).

/lib/PHPoAuthLib/src/OAuth/OAuth2/Service/Harvest.php  
  1. class Harvest extends AbstractService 
  2.  
  3. public function __construct( 
  4. CredentialsInterface $credentials,  
  5. ClientInterface $httpClient,  
  6. TokenStorageInterface $storage,  
  7. $scopes = array(),  
  8. UriInterface $baseApiUri = null 
  9. ) { 
  10. parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); 
  11.  
  12. if (null === $baseApiUri) { 
  13. $this->baseApiUri = new Uri('https://api.github.com/'); 
  14.  
  15. /** 
  16. * {@inheritdoc} 
  17. */ 
  18. public function getAuthorizationEndpoint() 
  19. return new Uri('https://api.harvestapp.com/oauth2/authorize'); 
  20.  
  21. /** 
  22. * {@inheritdoc} 
  23. */ 
  24. public function getAccessTokenEndpoint() 
  25. return new Uri('https://api.harvestapp.com/oauth2/token'); 
  26.  
  27. /** 
  28. * {@inheritdoc} 
  29. */ 
  30. protected function getAuthorizationMethod() 
  31. return static::AUTHORIZATION_METHOD_QUERY_STRING; 
  32.  
  33. /** 
  34. * {@inheritdoc} 
  35. */ 
  36. protected function parseAccessTokenResponse($responseBody) 
  37. $data = json_decode($responseBody, true); 
  38.  
  39. if (null === $data || ! is_array($data)) { 
  40. throw new TokenResponseException('Unable to parse response.'); 
  41. } elseif (isset($data['error'])) { 
  42. throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); 
  43.  
  44. $token = new StdOAuth2Token(); 
  45. $token->setAccessToken($data['access_token']); 
  46. $token->setEndOfLife($data['expires_in']); 
  47.  
  48. unset($data['access_token']); 
  49.  
  50. $token->setExtraParams($data); 
  51.  
  52. return $token; 
  53.  
  54. /** 
  55. * @return array 
  56. */ 
  57. protected function getExtraOAuthHeaders() 
  58. return array('Accept' => 'application/json');