Classes/Flowpack/SingleSignOn/Server/Controller/AccessTokenController.php
public function redeemAction($accessToken) {
		if ($this->request->getHttpRequest()->getMethod() !== 'POST') {
			$this->response->setStatus(405);
			$this->response->setHeader('Allow', 'POST');
			return;
		}

		$accessTokenObject = $this->accessTokenRepository->findByIdentifier($accessToken);
		if (!$accessTokenObject instanceof AccessToken) {
			$this->response->setStatus(404);
			$this->view->assign('value', array('message' => 'Invalid access token'));
			return;
		}

		$sessionId = $accessTokenObject->getSessionId();
		$session = $this->sessionManager->getSession($sessionId);
		if (!$this->sessionIsActive($session)) {
			$this->response->setStatus(403);
			$this->view->assign('value', array('message' => 'Session expired'));
			return;
		}

		$this->accessTokenRepository->remove($accessTokenObject);

		// TODO Move the actual logic of redemption to a service

		$ssoClient = $accessTokenObject->getSsoClient();
		$this->singleSignOnSessionManager->registerSsoClient($session, $ssoClient);

		// TODO Get the account from the global session
		// TODO What to do with multiple accounts?
		$account = $accessTokenObject->getAccount();
		$accountData = $this->clientAccountMapper->getAccountData($accessTokenObject->getSsoClient(), $account);

		if ($this->ssoLogger !== NULL) {
			$this->ssoLogger->log('Redeemed access token "' . $accessToken . '" from client "' . $ssoClient->getServiceBaseUri() . '" for session "' . $sessionId . '" and account "' . $account->getAccountIdentifier() . '"', LOG_INFO);
		}

		$this->response->setStatus(201);

		$this->view->assign('value', array(
			'account' => $accountData,
			'sessionId' => $sessionId
		));
	}
public function redeemAction($accessToken) {
		if ($this->request->getHttpRequest()->getMethod() !== 'POST') {
			$this->response->setStatus(405);
			$this->response->setHeader('Allow', 'POST');
			return;
		}

		$accessTokenObject = $this->accessTokenRepository->findByIdentifier($accessToken);
		if (!$accessTokenObject instanceof AccessToken) {
			$this->response->setStatus(404);
			$this->view->assign('value', array('message' => 'Invalid access token'));
			return;
		}

		$sessionId = $accessTokenObject->getSessionId();
		$session = $this->sessionManager->getSession($sessionId);
		if (!$this->sessionIsActive($session)) {
			$this->response->setStatus(403);
			$this->view->assign('value', array('message' => 'Session expired'));
			return;
		}

		$this->accessTokenRepository->remove($accessTokenObject);

		// TODO Move the actual logic of redemption to a service

		$ssoClient = $accessTokenObject->getSsoClient();
		$this->singleSignOnSessionManager->registerSsoClient($session, $ssoClient);

		// TODO Get the account from the global session
		// TODO What to do with multiple accounts?
		$account = $accessTokenObject->getAccount();
		$accountData = $this->clientAccountMapper->getAccountData($accessTokenObject->getSsoClient(), $account);

		if ($this->ssoLogger !== NULL) {
			$this->ssoLogger->log('Redeemed access token "' . $accessToken . '" from client "' . $ssoClient->getServiceBaseUri() . '" for session "' . $sessionId . '" and account "' . $account->getAccountIdentifier() . '"', LOG_INFO);
		}

		$this->response->setStatus(201);

		$this->view->assign('value', array(
			'account' => $accountData,
			'sessionId' => $sessionId
		));
	}
public function redeemAction ( $ accessToken ) { if ( $ this -> request -> getHttpRequest ( ) -> getMethod ( ) !== 'POST' ) { $ this -> response -> setStatus ( 405 ) ; $ this -> response -> setHeader ( 'Allow' , 'POST' ) ; return ; } $ accessTokenObject = $ this -> accessTokenRepository -> findByIdentifier ( $ accessToken ) ; if ( ! $ accessTokenObject instanceof AccessToken ) { $ this -> response -> setStatus ( 404 ) ; $ this -> view -> assign ( 'value' , array ( 'message' => 'Invalid access token' ) ) ; return ; } $ sessionId = $ accessTokenObject -> getSessionId ( ) ; $ session = $ this -> sessionManager -> getSession ( $ sessionId ) ; if ( ! $ this -> sessionIsActive ( $ session ) ) { $ this -> response -> setStatus ( 403 ) ; $ this -> view -> assign ( 'value' , array ( 'message' => 'Session expired' ) ) ; return ; } $ this -> accessTokenRepository -> remove ( $ accessTokenObject ) ; // TODO Move the actual logic of redemption to a service $ ssoClient = $ accessTokenObject -> getSsoClient ( ) ; $ this -> singleSignOnSessionManager -> registerSsoClient ( $ session , $ ssoClient ) ; // TODO Get the account from the global session // TODO What to do with multiple accounts? $ account = $ accessTokenObject -> getAccount ( ) ; $ accountData = $ this -> clientAccountMapper -> getAccountData ( $ accessTokenObject -> getSsoClient ( ) , $ account ) ; if ( $ this -> ssoLogger !== NULL ) { $ this -> ssoLogger -> log ( 'Redeemed access token "' . $ accessToken . '" from client "' . $ ssoClient -> getServiceBaseUri ( ) . '" for session "' . $ sessionId . '" and account "' . $ account -> getAccountIdentifier ( ) . '"' , LOG_INFO ) ; } $ this -> response -> setStatus ( 201 ) ; $ this -> view -> assign ( 'value' , array ( 'account' => $ accountData , 'sessionId' => $ sessionId ) ) ; }
Redeem an access token and return global account data for the authenticated account
and a global session id.

POST token/{accessToken}/redeem?clientSessionId=abc

@param string $accessToken
Redeem an access token and return global account data for the authenticated account and a global session id .