private function requestToken($code, $tokenType) {
		$authApi = new PestJSON("{$_SESSION[self::SESSION][self::OAUTH_ENDPOINT]}");
		try {
			$response = $authApi->post('token',
				array(
					self::CLIENT_ID => $_SESSION[self::SESSION][self::CLIENT_ID],
					self::REDIRECT_URI => $_SESSION[self::SESSION][self::REDIRECT_URI],
					self::STATE => self::$SCOPES[$tokenType][self::TOKEN_PROVIDED],
					self::CLIENT_SECRET => $_SESSION[self::SESSION][self::CLIENT_SECRET],
					self::CODE => $code,
				)
			);
		} catch (Pest_ServerError $e) {
			echo $e->getMessage();
			exit;
		}
		if ($response) {
			if (isset($response['access_token'])) {
				$_SESSION[self::SESSION][self::TOKEN] = $response['access_token'];
				return true;
			} else {
				throw new OAuthNegotiator_Exception(
					'Access token not received',
					OAuthNegotiator_Exception::TOKEN_RESPONSE
				);
			}
		} else {
			throw new OAuthNegotiator_Exception(
				'Unexpected OAuth response',
				OAuthNegotiator_Exception::TOKEN_RESPONSE
			);
		}
	}
private function requestToken($code, $tokenType) {
		$authApi = new PestJSON("{$_SESSION[self::SESSION][self::OAUTH_ENDPOINT]}");
		try {
			$response = $authApi->post('token',
				array(
					self::CLIENT_ID => $_SESSION[self::SESSION][self::CLIENT_ID],
					self::REDIRECT_URI => $_SESSION[self::SESSION][self::REDIRECT_URI],
					self::STATE => self::$SCOPES[$tokenType][self::TOKEN_PROVIDED],
					self::CLIENT_SECRET => $_SESSION[self::SESSION][self::CLIENT_SECRET],
					self::CODE => $code,
				)
			);
		} catch (Pest_ServerError $e) {
			echo $e->getMessage();
			exit;
		}
		if ($response) {
			if (isset($response['access_token'])) {
				$_SESSION[self::SESSION][self::TOKEN] = $response['access_token'];
				return true;
			} else {
				throw new OAuthNegotiator_Exception(
					'Access token not received',
					OAuthNegotiator_Exception::TOKEN_RESPONSE
				);
			}
		} else {
			throw new OAuthNegotiator_Exception(
				'Unexpected OAuth response',
				OAuthNegotiator_Exception::TOKEN_RESPONSE
			);
		}
	}
private function requestToken ( $ code , $ tokenType ) { $ authApi = new PestJSON ( "{$_SESSION[self::SESSION][self::OAUTH_ENDPOINT]}" ) ; try { $ response = $ authApi -> post ( 'token' , array ( self :: CLIENT_ID => $ _SESSION [ self :: SESSION ] [ self :: CLIENT_ID ] , self :: REDIRECT_URI => $ _SESSION [ self :: SESSION ] [ self :: REDIRECT_URI ] , self :: STATE => self :: $ SCOPES [ $ tokenType ] [ self :: TOKEN_PROVIDED ] , self :: CLIENT_SECRET => $ _SESSION [ self :: SESSION ] [ self :: CLIENT_SECRET ] , self :: CODE => $ code , ) ) ; } catch ( Pest_ServerError $ e ) { echo $ e -> getMessage ( ) ; exit ; } if ( $ response ) { if ( isset ( $ response [ 'access_token' ] ) ) { $ _SESSION [ self :: SESSION ] [ self :: TOKEN ] = $ response [ 'access_token' ] ; return true ; } else { throw new OAuthNegotiator_Exception ( 'Access token not received' , OAuthNegotiator_Exception :: TOKEN_RESPONSE ) ; } } else { throw new OAuthNegotiator_Exception ( 'Unexpected OAuth response' , OAuthNegotiator_Exception :: TOKEN_RESPONSE ) ; } }
Request a token from the OAuth server

@param string $code An authorization code provided by the OAuth server
@param string $tokenType Type of token being requested (IDENTITY_TOKEN|API_TOKEN)

@return void Updates session variables

@throws OAuthNegotiator_Exception TOKEN_RESPONSE if a token no token is received or on any other uanticipated response from the OAuth server
Request a token from the OAuth server