Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revoking token #1031

Open
cgkronos opened this issue Sep 12, 2022 · 0 comments
Open

Revoking token #1031

cgkronos opened this issue Sep 12, 2022 · 0 comments

Comments

@cgkronos
Copy link

I'm trying to revoke a token in php using this lib but I keep getting a false after calling handleRevokeRequest I'm struggling to find working example on the web

public function revokeToken($token, $sendError = true, $method = null)
    {
        require_once dirname(__FILE__) . '/vendor/autoload.php';
        require_once dirname(__FILE__) . '/OAuthStorage.class.php';
        OAuth2\Autoloader::register();

        $storage = new OAuth2\Storage\OvidentiaOAuthStorage();
        $server = new OAuth2\Server($storage);

        // Add the 'Authorization Code' grant type (this is where the oauth magic happens)


        $server->addGrantType(new OAuth2\GrantType\AuthorizationCode($storage));

        if ($method == null) {
            $method = $_SERVER['REQUEST_METHOD'];
        }

        $request = new OAuth2\Request(array(), array('token' => $token), array(), array(), array(), array('REQUEST_METHOD' => $method));


        if (!$server->handleRevokeRequest($request)) {
            if ($sendError === true) {
                $server->getResponse()->send();                
                die;
            } else {
                $this->errorMessages = array();
                $error = $server->getResponse()->getParameters();
                if (isset($error['error_description'])) {
                    var_dump($error['error_description']);
                    $this->errorMessages[] = $error['error_description'];
                }
                return false;
            }
        } else {
            var_dump("else");
        }

        return true;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant