public static function getAccessToken($code, $redirect_uri) { $params = array('client_id' => self::$client_id, 'client_secret' => self::$client_secret, 'grant_type' => 'authorization_code', 'code' => $code, 'redirect_uri' => $redirect_uri); return self::$accessTokenURL . '?' . http_build_query($params); }
public function actionCallback($oauth_token) { try { $login_secret = $this->getSession('oauth')->login_secret; if (!$oauth_token) { echo "Error! There is no OAuth token!"; exit; } if (!$login_secret) { echo "Error! There is no OAuth secret!"; exit; } $this->oauth->enableDebug(); $this->oauth->setToken($oauth_token, $login_secret); $access_token_info = $this->oauth->getAccessToken(self::ACCESS_TOKEN_URL); $this->getSession('oauth')->login_secret = false; $this->getSession('oauth')->token = $access_token_info['oauth_token']; $this->getSession('oauth')->secret = $access_token_info['oauth_token_secret']; $this->getUserDetailsAndLoginUser(); } catch (OAuthException $E) { Debugger::log($E); //zalogujeme for sichr echo "OAuth login failed. Please, contact administrator."; $this->terminate(); } }