I try to use a API for a logout process, in the documentation of the api give a endpoint for it "https://example.com/logout", this is a GET request, i need to send a token, state , and url_post_logout (for redirect). I was login with a user account(and take the token and the others parameters), when i use the endpoint for logout on POSTMAN sending the query params 'token', 'state' , and 'url_post_logout'. show status 200 and do a redirect to my homepage or to the url_post_logout with the session closed (works!).

But in my code i try to do the same and show error '403 Forbidden' but close the session (almost works).

    $endpoint = "https://example.com/logout";
    $client = \Drupal::httpClient();
    $response_logout = $client->get($endpoint, [
          'query' => [
            'url_post_logout' => $base_url,
            'token' => $_SESSION['token'],
            'state' => 'state123',],
    }catch(\Exception e){
          $error_binds = array(
            '%error' => print_r($e->getMessage(), TRUE)
          $error = t((string) $error_binds);
          throw new \Exception($error, $e->getCode(), $e);

Any ideas or suggestions? Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.