Skip to content

Logout

Description

The Logout operation terminates user session and disassociates the AuthenticatedUser role from the subsequent requests made by the client application.

Method

GET

Endpoint URL

The xxxx.backendless.app is a subdomain assigned to your application. For more information see the Client-side Setup section of this documentation.

https://xxxx.backendless.app/api/users/logout

Request Headers

user-token: value-of-the-user-token-header-from-login

where

Argument                Description
user-token A value returned by Backendless in the response for the preceding Login operation. The value identifies the user to be logged out. This header is mandatory.

Request Body

None.

Response Body

None.

Example

The example below terminates the user session.

Important

Make sure to replace xxxx in the domain name in the sample request below to the one assigned to your application.

curl   
  -H user-token:value-of-user-token-from-login  
  -v   
  https://xxxx.backendless.app/api/users/logout 

Errors

When the server-side reports an error, it returns a JSON object in the following format:

{  
  "message":error-message,  
  "code":error-code  
}

The following errors may occur during the Logout API call.

Error Code
Description
2002
Version is disabled or provided wrong application info (application id or secret key)
3007
Invalid application-id or version.
3023
General error while executing logout. Error details should be available in the message property.

Codeless Reference

user_service_codeless_logout_current_user

This operation does not return a value.

Consider the following record in the Users data table:
user_service_codeless_example_get_user_roles_example_1

The example below logs in as "alice@wonderland.com", retrieves the user token, and terminates the current session by invoking the Logout operation.  The user token is required for successful Logout operation.

user_service_codeless_example_logout_current_user