/** * Handle state "OK" - run authentication. * * @return void */ protected function handleStateOK() { $this->log(__METHOD__); if ($accessToken = $this->getAccessToken()) { try { $this->credentials = $this->getRublon()->getCredentials($accessToken); } catch (RublonException $e) { throw new RublonCallbackException("Rublon API credentials error.", RublonCallbackException::ERROR_REST_CREDENTIALS, $e); } // Authenticate user: $this->success($this->credentials->getUserId()); } else { throw new RublonCallbackException("Missing access token.", RublonCallbackException::ERROR_MISSING_ACCESS_TOKEN); } }
/** * Authenticate user and get user's credentials using one-time use access token and expected user's profile ID. * * One-time use access token is a session identifier which will be deleted after first usage. * This method can be called only once in authentication process. * * @param string $accessToken One-time use access token * @return RublonAPICredentials * @throws RublonException */ public function getCredentials($accessToken) { if (isset($this->cacheCredentials[$accessToken])) { $this->log('return cached credentials'); return $this->cacheCredentials[$accessToken]; } else { $credentials = new RublonAPICredentials($this, $accessToken); $credentials->perform(); $this->cacheCredentials[$accessToken] = $credentials; return $credentials; } }
/** * Get credentials after authentication. * * @param string $accessToken * @return RublonAPICredentials */ function getCredentials($accessToken) { $credentials = new RublonAPICredentials($this, $accessToken); $credentials->perform(); return $credentials; }