src/OAuth2/Controller/ResourceController.php
public function getAccessTokenData(RequestInterface $request, ResponseInterface $response)
    {
        // Get the token parameter
        if ($token_param = $this->tokenType->getAccessTokenParameter($request, $response)) {
            // Get the stored token data (from the implementing subclass)
            // Check we have a well formed token
            // Check token expiration (expires is a mandatory paramter)
            if (!$token = $this->tokenStorage->getAccessToken($token_param)) {
                $response->setError(401, 'invalid_token', 'The access token provided is invalid');
            } elseif (!isset($token["expires"]) || !isset($token["client_id"])) {
                $response->setError(401, 'malformed_token', 'Malformed token (missing "expires")');
            } elseif (time() > $token["expires"]) {
                $response->setError(401, 'invalid_token', 'The access token provided has expired');
            } else {
                return $token;
            }
        }

        $authHeader = sprintf('%s realm="%s"', $this->tokenType->getTokenType(), $this->config['www_realm']);

        if ($error = $response->getParameter('error')) {
            $authHeader = sprintf('%s, error="%s"', $authHeader, $error);
            if ($error_description = $response->getParameter('error_description')) {
                $authHeader = sprintf('%s, error_description="%s"', $authHeader, $error_description);
            }
        }

        $response->addHttpHeaders(array('WWW-Authenticate' => $authHeader));

        return null;
    }
public function getAccessTokenData(RequestInterface $request, ResponseInterface $response)
    {
        // Get the token parameter
        if ($token_param = $this->tokenType->getAccessTokenParameter($request, $response)) {
            // Get the stored token data (from the implementing subclass)
            // Check we have a well formed token
            // Check token expiration (expires is a mandatory paramter)
            if (!$token = $this->tokenStorage->getAccessToken($token_param)) {
                $response->setError(401, 'invalid_token', 'The access token provided is invalid');
            } elseif (!isset($token["expires"]) || !isset($token["client_id"])) {
                $response->setError(401, 'malformed_token', 'Malformed token (missing "expires")');
            } elseif (time() > $token["expires"]) {
                $response->setError(401, 'invalid_token', 'The access token provided has expired');
            } else {
                return $token;
            }
        }

        $authHeader = sprintf('%s realm="%s"', $this->tokenType->getTokenType(), $this->config['www_realm']);

        if ($error = $response->getParameter('error')) {
            $authHeader = sprintf('%s, error="%s"', $authHeader, $error);
            if ($error_description = $response->getParameter('error_description')) {
                $authHeader = sprintf('%s, error_description="%s"', $authHeader, $error_description);
            }
        }

        $response->addHttpHeaders(array('WWW-Authenticate' => $authHeader));

        return null;
    }
public function getAccessTokenData ( RequestInterface $ request , ResponseInterface $ response ) { // Get the token parameter if ( $ token_param = $ this -> tokenType -> getAccessTokenParameter ( $ request , $ response ) ) { // Get the stored token data (from the implementing subclass) // Check we have a well formed token // Check token expiration (expires is a mandatory paramter) if ( ! $ token = $ this -> tokenStorage -> getAccessToken ( $ token_param ) ) { $ response -> setError ( 401 , 'invalid_token' , 'The access token provided is invalid' ) ; } elseif ( ! isset ( $ token [ "expires" ] ) || ! isset ( $ token [ "client_id" ] ) ) { $ response -> setError ( 401 , 'malformed_token' , 'Malformed token (missing "expires")' ) ; } elseif ( time ( ) > $ token [ "expires" ] ) { $ response -> setError ( 401 , 'invalid_token' , 'The access token provided has expired' ) ; } else { return $ token ; } } $ authHeader = sprintf ( '%s realm="%s"' , $ this -> tokenType -> getTokenType ( ) , $ this -> config [ 'www_realm' ] ) ; if ( $ error = $ response -> getParameter ( 'error' ) ) { $ authHeader = sprintf ( '%s, error="%s"' , $ authHeader , $ error ) ; if ( $ error_description = $ response -> getParameter ( 'error_description' ) ) { $ authHeader = sprintf ( '%s, error_description="%s"' , $ authHeader , $ error_description ) ; } } $ response -> addHttpHeaders ( array ( 'WWW-Authenticate' => $ authHeader ) ) ; return null ; }
Get access token data.

@param RequestInterface  $request
@param ResponseInterface $response
@return array|null
Get access token data .