Ejemplo n.º 1
0
 public function fetchWithRefreshToken(tubepress_spi_http_oauth2_Oauth2ProviderInterface $provider, tubepress_api_http_oauth_v2_TokenInterface $token)
 {
     $tokenUrl = $provider->getTokenEndpoint();
     $clientId = $this->_persistenceHelper->getClientId($provider);
     $clientSecret = $this->_persistenceHelper->getClientSecret($provider);
     $request = $this->_httpClient->createRequest('POST', $tokenUrl, array('body' => array('grant_type' => 'refresh_token', 'refresh_token' => $token->getRefreshToken())));
     $provider->onRefreshTokenRequest($request, $token, $clientId, $clientSecret);
     return $this->_fetchAndBuildToken($request, $provider);
 }
Ejemplo n.º 2
0
 public function saveToken(tubepress_spi_http_oauth2_Oauth2ProviderInterface $provider, $slug, tubepress_api_http_oauth_v2_TokenInterface $token)
 {
     $tokens = $this->_context->get(tubepress_api_options_Names::OAUTH2_TOKENS);
     $decoded = json_decode($tokens, true);
     $providerName = $provider->getName();
     if (!isset($decoded[$providerName])) {
         $decoded[$providerName] = array();
     }
     $providerTokens = $decoded[$providerName];
     $toSave = array(self::$_ACCESS_TOKEN => $token->getAccessToken(), self::$_EXPIRY_UNIX => $token->getEndOfLifeUnixTime(), self::$_EXTRA => $token->getExtraParams());
     if ($token->getRefreshToken()) {
         $toSave[self::$_REFRESH_TOKEN] = $token->getRefreshToken();
     }
     $providerTokens[$slug] = $toSave;
     $decoded[$providerName] = $providerTokens;
     $this->_persistence->queueForSave(tubepress_api_options_Names::OAUTH2_TOKENS, json_encode($decoded));
     $this->_persistence->flushSaveQueue();
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function authorizeRequest(tubepress_api_http_message_RequestInterface $request, tubepress_api_http_oauth_v2_TokenInterface $token, $clientId, $clientSecret = null)
 {
     $request->setHeader('Authorization', 'bearer ' . $token->getAccessToken());
     $request->setHeader('Accept', 'application/vnd.vimeo.*+json;version=3.2');
 }