Skip to main content
added 332 characters in body
Source Link

To logout using REST in Drupal 8, you can just do a POST with Content-type: application/jsonPOST to:

https://example.com/user/logout?_format=json_format=json&token=logout_token

Use the following headers on your request:

  • Content-type: application/json
  • X-CSRF-Token: csrf_token

The values for logout_token and csrf_token are available in the login response.

Be sure to visit admin/config/services/rest and enable the following for the User resource:

  • methods: POST
  • formats: json
  • authentication: cookie

Earlier versions of Drupal 8

Do a GET on ?q=user/logout

This is noted in the JS D8 REST docs: https://www.drupal.org/docs/8/core/modules/rest/javascript-and-drupal-8-restful-web-services

Although it should not matter, the Content-type may need to be set to application/x-www-form-urlencoded.

Here's an example usage from jDrupal: https://github.com/signalpoint/jDrupal/blob/8.x-1.x/src/includes/rest.inc.js#L113

To logout using REST in Drupal 8, you can just do a POST with Content-type: application/json to:

https://example.com/user/logout?_format=json

Earlier versions of Drupal 8

Do a GET on ?q=user/logout

This is noted in the JS D8 REST docs: https://www.drupal.org/docs/8/core/modules/rest/javascript-and-drupal-8-restful-web-services

Although it should not matter, the Content-type may need to be set to application/x-www-form-urlencoded.

Here's an example usage from jDrupal: https://github.com/signalpoint/jDrupal/blob/8.x-1.x/src/includes/rest.inc.js#L113

To logout using REST in Drupal 8, you can do a POST to:

https://example.com/user/logout?_format=json&token=logout_token

Use the following headers on your request:

  • Content-type: application/json
  • X-CSRF-Token: csrf_token

The values for logout_token and csrf_token are available in the login response.

Be sure to visit admin/config/services/rest and enable the following for the User resource:

  • methods: POST
  • formats: json
  • authentication: cookie

Earlier versions of Drupal 8

Do a GET on ?q=user/logout

This is noted in the JS D8 REST docs: https://www.drupal.org/docs/8/core/modules/rest/javascript-and-drupal-8-restful-web-services

Although it should not matter, the Content-type may need to be set to application/x-www-form-urlencoded.

Here's an example usage from jDrupal: https://github.com/signalpoint/jDrupal/blob/8.x-1.x/src/includes/rest.inc.js#L113

Update answer for latest Drupal 8 usage.
Source Link

To logout using REST in Drupal 8, you can just do a POST with Content-type: application/json to:

https://example.com/user/logout?_format=json

Earlier versions of Drupal 8

Do a GET on ?q=user/logout.

This is noted in the JS D8 REST docs: https://www.drupal.org/docs/8/core/modules/rest/javascript-and-drupal-8-restful-web-services

Although it should not matter, the Content-type may need to be set to application/x-www-form-urlencoded.

Here's an example usage from jDrupal: https://github.com/signalpoint/jDrupal/blob/8.x-1.x/src/includes/rest.inc.js#L113

To logout using REST in Drupal 8, you can just do a GET on ?q=user/logout.

This is noted in the JS D8 REST docs: https://www.drupal.org/docs/8/core/modules/rest/javascript-and-drupal-8-restful-web-services

Although it should not matter, the Content-type may need to be set to application/x-www-form-urlencoded.

Here's an example usage from jDrupal: https://github.com/signalpoint/jDrupal/blob/8.x-1.x/src/includes/rest.inc.js#L113

To logout using REST in Drupal 8, you can just do a POST with Content-type: application/json to:

https://example.com/user/logout?_format=json

Earlier versions of Drupal 8

Do a GET on ?q=user/logout

This is noted in the JS D8 REST docs: https://www.drupal.org/docs/8/core/modules/rest/javascript-and-drupal-8-restful-web-services

Although it should not matter, the Content-type may need to be set to application/x-www-form-urlencoded.

Here's an example usage from jDrupal: https://github.com/signalpoint/jDrupal/blob/8.x-1.x/src/includes/rest.inc.js#L113

added 235 characters in body
Source Link

To logout using REST in Drupal 8, you can just do a GET on ?q=user/logout.

This is noted in the JS D8 REST docs: https://www.drupal.org/docs/8/core/modules/rest/javascript-and-drupal-8-restful-web-services

Although it should not matter, the Content-type may need to be set to application/x-www-form-urlencoded.

Here's an example usage from jDrupal: https://github.com/signalpoint/jDrupal/blob/8.x-1.x/src/includes/rest.inc.js#L113

To logout using REST in Drupal 8, you can just do a GET on ?q=user/logout.

This is noted in the JS D8 REST docs: https://www.drupal.org/docs/8/core/modules/rest/javascript-and-drupal-8-restful-web-services

To logout using REST in Drupal 8, you can just do a GET on ?q=user/logout.

This is noted in the JS D8 REST docs: https://www.drupal.org/docs/8/core/modules/rest/javascript-and-drupal-8-restful-web-services

Although it should not matter, the Content-type may need to be set to application/x-www-form-urlencoded.

Here's an example usage from jDrupal: https://github.com/signalpoint/jDrupal/blob/8.x-1.x/src/includes/rest.inc.js#L113

Source Link
Loading