/**
  * @param tubepress_spi_http_oauth2_Oauth2ProviderInterface $provider
  * @param $code
  *
  * @return tubepress_api_http_oauth_v2_TokenInterface
  */
 public function fetchWithCodeGrant(tubepress_spi_http_oauth2_Oauth2ProviderInterface $provider, $code)
 {
     $tokenUrl = $provider->getTokenEndpoint();
     $redirectUri = $this->_oauth2Environment->getRedirectionUrl($provider);
     $request = $this->_httpClient->createRequest('POST', $tokenUrl, array('body' => array('code' => $code, 'grant_type' => 'authorization_code', 'redirect_uri' => "{$redirectUri}")));
     $clientId = $this->_persistenceHelper->getClientId($provider);
     $clientSecret = $this->_persistenceHelper->getClientSecret($provider);
     $provider->onAccessTokenRequest($request, $clientId, $clientSecret);
     return $this->_fetchAndBuildToken($request, $provider);
 }
 /**
  * {@inheritdoc}
  */
 protected function getTemplateVariables()
 {
     $redirectUrl = $this->_oauth2Environment->getRedirectionUrl($this->_provider);
     $instructions = $this->_provider->getTranslatedClientRegistrationInstructions($this->_translator, $redirectUrl);
     return array('translatedInstructions' => $instructions);
 }