Set Current User Token¶
Description¶
This operation allows setting a new user-token
for the current user in the application. The authorization token or user-token
is used to maintain the user session, and it uniquely identifies both the user and the session on the server and is used to enforce security policy, apply user and roles permissions and track usage analytics. The authorization token is not stored in the Users
data table, but is uniquely generated on every successful login.
When the session expires and this operation is used, the Backendless servers send a new token to the client application to maintain the session.
Method¶
[Backendless.shared.userService setUserTokenWithValue:(NSString *)userToken];
Backendless.shared.userService.setUserToken(userToken)
where:
Argument | Description |
---|---|
userToken |
A string value uniquely identifying guest user's session. String value. |
Return value¶
The newly assigned token.
Example¶
The example below sets a new user-token "B8D5D11C-6E07-4E0D-A3F9-B8015F9E4391"
for the currently logged in user.
[Backendless.shared.userService setUserTokenWithValue:@"B8D5D11C-6E07-4E0D-A3F9-B8015F9E4391"];
Backendless.shared.userService.setUserToken(value: "B8D5D11C-6E07-4E0D-A3F9-B8015F9E4391")
Codeless Reference¶
Returns the newly assigned token.
Consider the following record in the Users
data table:
The example below logs in as "alice@wonderland.com"
and sets a new user-token "B8D5D11C-6E07-4E0D-A3F9-B8015F9E4391"
.