/** * {@inheritdoc} */ public function loginFinish() { $oauth_token = array_key_exists('oauth_token', $_REQUEST) ? $_REQUEST['oauth_token'] : ""; $oauth_verifier = array_key_exists('oauth_verifier', $_REQUEST) ? $_REQUEST['oauth_verifier'] : ""; if (!$oauth_token || !$oauth_verifier) { throw new Exception("Authentication failed! {$this->providerId} returned an invalid oauth verifier.", 5); } // request an access token $tokens = $this->api->accessToken($oauth_verifier); // access tokens as received from provider $this->access_tokens_raw = $tokens; // check the last HTTP status code returned if ($this->api->http_code != 200) { throw new Exception("Authentication failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code), 5); } // we should have an access_token, or else, something has gone wrong if (!isset($tokens["oauth_token"])) { throw new Exception("Authentication failed! {$this->providerId} returned an invalid access token.", 5); } // we no more need to store request tokens $this->deleteToken("request_token"); $this->deleteToken("request_token_secret"); // store access_token for later user $this->token("access_token", $tokens['oauth_token']); $this->token("access_token_secret", $tokens['oauth_token_secret']); // set user as logged in to the current provider $this->setUserConnected(); }
public function __construct($consumer_key, $consumer_secret) { parent::__construct($consumer_key, $consumer_secret); // set request token url $this->request_token_url = IC_OAUTH_REQUEST_TOKEN_URL; $this->access_token_url = IC_OAUTH_ACCESS_TOKEN_URL; self::$store = new IC_Storage(); $this->init(); }