OAuthOAuth2ServiceVkontakte

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

Defined (1)

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

/lib/PHPoAuthLib/src/OAuth/OAuth2/Service/Vkontakte.php  
  1. class Vkontakte extends AbstractService 
  2. /** 
  3. * Defined scopes 
  4. * @link http://vk.com/dev/permissions 
  5. */ 
  6. const SCOPE_NOTIFY = 'notify'; 
  7. const SCOPE_FRIENDS = 'friends'; 
  8. const SCOPE_PHOTOS = 'photos'; 
  9. const SCOPE_AUDIO = 'audio'; 
  10. const SCOPE_VIDEO = 'video'; 
  11. const SCOPE_DOCS = 'docs'; 
  12. const SCOPE_NOTES = 'notes'; 
  13. const SCOPE_PAGES = 'pages'; 
  14. const SCOPE_APP_LINK = ''; 
  15. const SCOPE_STATUS = 'status'; 
  16. const SCOPE_OFFERS = 'offers'; 
  17. const SCOPE_QUESTIONS = 'questions'; 
  18. const SCOPE_WALL = 'wall'; 
  19. const SCOPE_GROUPS = 'groups'; 
  20. const SCOPE_MESSAGES = 'messages'; 
  21. const SCOPE_NOTIFICATIONS = 'notifications'; 
  22. const SCOPE_STATS = 'stats'; 
  23. const SCOPE_ADS = 'ads'; 
  24. const SCOPE_OFFLINE = 'offline'; 
  25. const SCOPE_NOHTTPS = 'nohttps'; 
  26.  
  27. public function __construct( 
  28. CredentialsInterface $credentials,  
  29. ClientInterface $httpClient,  
  30. TokenStorageInterface $storage,  
  31. $scopes = array(),  
  32. UriInterface $baseApiUri = null 
  33. ) { 
  34. parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); 
  35.  
  36. if (null === $baseApiUri) { 
  37. $this->baseApiUri = new Uri('https://api.vk.com/method/'); 
  38.  
  39. /** 
  40. * {@inheritdoc} 
  41. */ 
  42. public function getAuthorizationEndpoint() 
  43. return new Uri('https://oauth.vk.com/authorize'); 
  44.  
  45. /** 
  46. * {@inheritdoc} 
  47. */ 
  48. public function getAccessTokenEndpoint() 
  49. return new Uri('https://oauth.vk.com/access_token'); 
  50.  
  51. /** 
  52. * {@inheritdoc} 
  53. */ 
  54. protected function parseAccessTokenResponse($responseBody) 
  55. $data = json_decode($responseBody, true); 
  56.  
  57. if (null === $data || !is_array($data)) { 
  58. throw new TokenResponseException('Unable to parse response.'); 
  59. } elseif (isset($data['error'])) { 
  60. throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); 
  61.  
  62. $token = new StdOAuth2Token(); 
  63. $token->setAccessToken($data['access_token']); 
  64. $token->setLifeTime($data['expires_in']); 
  65.  
  66. if (isset($data['refresh_token'])) { 
  67. $token->setRefreshToken($data['refresh_token']); 
  68. unset($data['refresh_token']); 
  69.  
  70. unset($data['access_token']); 
  71. unset($data['expires_in']); 
  72.  
  73. $token->setExtraParams($data); 
  74.  
  75. return $token; 
  76.  
  77. /** 
  78. * {@inheritdoc} 
  79. */ 
  80. protected function getAuthorizationMethod() 
  81. return static::AUTHORIZATION_METHOD_QUERY_STRING;