/** * Connect Step 2 * * @return null */ public function actionConnectStep2() { $providerHandle = craft()->httpSession->get('oauth.console.providerHandle'); $referer = craft()->httpSession->get('oauth.console.referer'); // connect $provider = craft()->oauth->getProvider($providerHandle); if ($response = craft()->oauth->connect(array('plugin' => 'oauth', 'provider' => $providerHandle))) { if ($response['success']) { // token $token = $response['token']; $tokenArray = OauthHelper::tokenToArray($token); // save token craft()->httpSession->add('oauth.console.token.' . $providerHandle, $tokenArray); // session notice craft()->userSession->setNotice(Craft::t("Connected.")); } else { craft()->userSession->setError(Craft::t($response['errorMsg'])); } } else { // session error craft()->userSession->setError(Craft::t("Couldn’t connect")); } // redirect $this->redirect($referer); }