I have a headless application in Drupal 8 I use as data provider. I am trying to log in and log out using user/login?_format=json and user/logout?_format=json.

I followed the Drupal 8 documentation for the approach.

The login request returns the following data.


In the logout request I use the logout token.


The code for the logout request is the following.

axios.post(`user/logout`, null, {
      headers: {
        'Content-Type': 'application/json',
        'X-CSRF-Token' : context.getters.getTokenCSRF,
      params: {
        _format: 'json',
        token: context.getters.getTokenLogout,
      'withCredentials': true,
  • If anyone comes across this please try to follow drupal documentation thoroughly, this issue is fixed now. Documentation link for rest api with javascript and drupal 8 thttps://www.drupal.org/docs/8/core/modules/rest/javascript-and-drupal-8-restful-web-services#s-login – Abhay Pai Apr 16 at 4:21

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.