OAuthOAuth2ServiceYammer

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

Defined (1)

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

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