stevenmaguire / oauth2-keycloak

Keycloak Provider for OAuth 2.0 Client
MIT License
204 stars 151 forks source link

Logout problem #37

Open TomaszPekalski opened 3 years ago

TomaszPekalski commented 3 years ago

hey, could You help me with logout option.

$client = $this->clientRegistry->getClient('keycloak');
  $logoutUrl = $client->getOAuth2Provider()->getLogoutUrl();
  $response = $client->getOAuth2Provider()->getRequest('GET',$logoutUrl );

when i click logoutUrl on browser i can logout - but from application not

rds3006 commented 1 year ago

We are also facing the same issue. The logout is not working as expected and even after calling logout, it is not logging out from Keycloak and thus posing an issue. @TomaszPekalski did you get any solution for it ?

RanierePrates commented 10 months ago

I had this issue; basically, it was more of an understanding problem. I forgot to include an array in the getLogoutUrl with the access_token, and the provider's getRequest doesn't make the request; it just instantiates the GuzzleHttp\Psr7\Request.

    $logoutUrl = $provider->getLogoutUrl([
        'access_token' => $token,
    ]);

    try {
        $client = new \GuzzleHttp\Client();
        $request = $client->send(
            $provider->getRequest('GET', $logoutUrl)
        );
    } catch (Exception $e) {
        exit($e->getMessage());
    }