src/OAuth2/Controller/TokenController.php
public function revokeToken(RequestInterface $request, ResponseInterface $response)
    {
        if (strtolower($request->server('REQUEST_METHOD')) === 'options') {
            $response->addHttpHeaders(array('Allow' => 'POST, OPTIONS'));

            return null;
        }

        if (strtolower($request->server('REQUEST_METHOD')) !== 'post') {
            $response->setError(405, 'invalid_request', 'The request method must be POST when revoking an access token', '#section-3.2');
            $response->addHttpHeaders(array('Allow' => 'POST, OPTIONS'));

            return null;
        }

        $token_type_hint = $request->request('token_type_hint');
        if (!in_array($token_type_hint, array(null, 'access_token', 'refresh_token'), true)) {
            $response->setError(400, 'invalid_request', 'Token type hint must be either \'access_token\' or \'refresh_token\'');

            return null;
        }

        $token = $request->request('token');
        if ($token === null) {
            $response->setError(400, 'invalid_request', 'Missing token parameter to revoke');

            return null;
        }

        // @todo remove this check for v2.0
        if (!method_exists($this->accessToken, 'revokeToken')) {
            $class = get_class($this->accessToken);
            throw new RuntimeException("AccessToken {$class} does not implement required revokeToken method");
        }

        $this->accessToken->revokeToken($token, $token_type_hint);

        return true;
    }
public function revokeToken(RequestInterface $request, ResponseInterface $response)
    {
        if (strtolower($request->server('REQUEST_METHOD')) === 'options') {
            $response->addHttpHeaders(array('Allow' => 'POST, OPTIONS'));

            return null;
        }

        if (strtolower($request->server('REQUEST_METHOD')) !== 'post') {
            $response->setError(405, 'invalid_request', 'The request method must be POST when revoking an access token', '#section-3.2');
            $response->addHttpHeaders(array('Allow' => 'POST, OPTIONS'));

            return null;
        }

        $token_type_hint = $request->request('token_type_hint');
        if (!in_array($token_type_hint, array(null, 'access_token', 'refresh_token'), true)) {
            $response->setError(400, 'invalid_request', 'Token type hint must be either \'access_token\' or \'refresh_token\'');

            return null;
        }

        $token = $request->request('token');
        if ($token === null) {
            $response->setError(400, 'invalid_request', 'Missing token parameter to revoke');

            return null;
        }

        // @todo remove this check for v2.0
        if (!method_exists($this->accessToken, 'revokeToken')) {
            $class = get_class($this->accessToken);
            throw new RuntimeException("AccessToken {$class} does not implement required revokeToken method");
        }

        $this->accessToken->revokeToken($token, $token_type_hint);

        return true;
    }
public function revokeToken ( RequestInterface $ request , ResponseInterface $ response ) { if ( strtolower ( $ request -> server ( 'REQUEST_METHOD' ) ) === 'options' ) { $ response -> addHttpHeaders ( array ( 'Allow' => 'POST, OPTIONS' ) ) ; return null ; } if ( strtolower ( $ request -> server ( 'REQUEST_METHOD' ) ) !== 'post' ) { $ response -> setError ( 405 , 'invalid_request' , 'The request method must be POST when revoking an access token' , '#section-3.2' ) ; $ response -> addHttpHeaders ( array ( 'Allow' => 'POST, OPTIONS' ) ) ; return null ; } $ token_type_hint = $ request -> request ( 'token_type_hint' ) ; if ( ! in_array ( $ token_type_hint , array ( null , 'access_token' , 'refresh_token' ) , true ) ) { $ response -> setError ( 400 , 'invalid_request' , 'Token type hint must be either \'access_token\' or \'refresh_token\'' ) ; return null ; } $ token = $ request -> request ( 'token' ) ; if ( $ token === null ) { $ response -> setError ( 400 , 'invalid_request' , 'Missing token parameter to revoke' ) ; return null ; } // @todo remove this check for v2.0 if ( ! method_exists ( $ this -> accessToken , 'revokeToken' ) ) { $ class = get_class ( $ this -> accessToken ) ; throw new RuntimeException ( "AccessToken {$class} does not implement required revokeToken method" ) ; } $ this -> accessToken -> revokeToken ( $ token , $ token_type_hint ) ; return true ; }
Revoke a refresh or access token. Returns true on success and when tokens are invalid

Note: invalid tokens do not cause an error response since the client
cannot handle such an error in a reasonable way.  Moreover, the
purpose of the revocation request, invalidating the particular token,
is already achieved.

@param RequestInterface $request
@param ResponseInterface $response
@throws RuntimeException
@return bool|null
Revoke a refresh or access token . Returns true on success and when tokens are invalid