Retrieving User Roles By User ID¶
Description¶
This operation can be used to retrieve custom and system roles assigned to a user.
This functionality can be used only in CloudCode (Java, JS or Codeless), the reason for this restriction is that a malicious use of this API can easily compromise application's security. As a result, this API must be used from a controlled environment. It is important the REST API is used with the CloudCode API key.
Method¶
GET
Endpoint URL¶
https://api.backendless.com/<application-id>/<CLOUDCODE-api-key>/users/userroles/<userId>
where:
Argument | Description |
---|---|
<application-id> |
The ID of your application generated upon its creation. You can obtain the value in the Manage > App Settings section of the Backendless Console. |
<CLOUDCODE-api-key> |
CloudCode API key of your application. You can obtain the value in the Manage > App Settings section of the Backendless Console. |
<userId> |
Mandatory string argument representing a unique objectId of a record in the Users data table. String value. |
Request Headers¶
None.
Request Body¶
None.
Response Body¶
Returns a collection of user roles, found by corresponding user ID.
Example¶
The example below retrieves all roles associated with the objectId: 4D584E4D-05A3-4AC4-90C7-B80D1584E7AD.
curl --location --request GET 'https://api.backendless.com/28066942-8273-BE6Q-AAD4-A1ZK34948E11/DCBACAA6-EF5B-49AA-8013-7BDF7A3A9A6B/users/userroles/4D584E4D-05A3-4AC4-90C7-B80D1584E7AD'
Codeless Reference¶
where:
Argument | Description |
---|---|
user id |
Unique identifier of the user account to retrieve all roles assigned to the user. |
Important
This Codeless block is only available in CloudCode due to the security reasons. If this operation is exposed to users, then your application can be compromised.
Returns a list containing all roles associated with the user.
Consider the following record in the Users
data table:
The example below retrieves all roles of the user "alice@yourmail.com"
associated with the user id
(objectId): 4D584E4D-05A3-4AC4-90C7-B80D1584E7AD
.
The output will look as shown below after the Codeless logic runs: