Validating User Login¶
Description¶
The user-token
value can be saved in the client application so it can be used when the application is restarted. This helps in streamlining the user experience since the user of the application does not need to login again. However, when the application restarts, it needs to check if the underlying user token, and hence the user session is still valid. This can be accomplished with the API below:
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/isvalidusertoken/<userToken>
where:
Argument | Description |
---|---|
<userToken> |
user token to validate. The value of the user token is returned by Backendless as a result of the login API request. |
Request Headers¶
None.
Request Body¶
None.
Response Body¶
true
if the current user session(user token) is valid. Otherwise, returns false
.
Example¶
To validate the user session, the user must be logged in first, make sure to set the stayLoggedIn
argument to true
to persist the information about the login for the use by subsequent starts/sessions of the application. For more information refer to the Login topic.
The example below checks if the current session is valid.
Sample Request:
curl
-X GET
-v https://xxxx.backendless.app/api/users/isvalidusertoken/<userToken>
Codeless Reference¶
Returns true
if the current user session(user token) is valid. Otherwise, returns false
.
Consider the following record in the Users
data table:
The example below logs in as "alice@yourmail.com"
. The stay logged in
parameter must be set to true
to establish a persistent session. Then the session is validated by using the Is Valid User Session
Codeless block.