/**
  * Redirects to the service for requesting access
  *
  * This is the first step of oAuth authentication
  *
  * This implementation tries to abstract away differences between oAuth1 and oAuth2,
  * but might need to be overwritten for specific services
  */
 public function login()
 {
     if (is_a($this->oAuth, 'OAuth\\OAuth2\\Service\\AbstractService')) {
         /* oAuth2 handling */
         $url = $this->oAuth->getAuthorizationUri();
     } else {
         /* oAuth1 handling */
         // extra request needed for oauth1 to request a request token :-)
         $token = $this->oAuth->requestRequestToken();
         $url = $this->oAuth->getAuthorizationUri(array('oauth_token' => $token->getRequestToken()));
     }
     send_redirect($url);
 }
Esempio n. 2
0
 public function getAuthorizationUri(array $additionalParameters = [])
 {
     $state = uniqid();
     $this->storage->storeAuthorizationState($this->service(), $state);
     return parent::getAuthorizationUri(array_merge(['state' => $state], $additionalParameters));
 }