Skip to content

Retrieving Available User Roles

Description

This operation returns a list of the roles associated with the user account currently logged in to the Backendless application. If the request is sent without logging in, the system will return only one role - NotAuthenticatedUser.

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/userroles

Request Headers

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

where:

Argument                Description
user-token Optional header. Contains a value returned by Backendless in a preceding user Login API call. If user-token is set in the request, the API returns a list of roles associated with the logged in user, otherwise the  API returns the following roles: NotAuthenticatedUser, RestUser.

Request Body

None.

Response Body

Returns an array of roles assigned to the currently logged in user

[  
  "roleName 1",   
  "roleName 2"  
  ...  
  "roleName N"  
]

Example

The example below retrieves the current user roles as an array containing string values.

curl --location --request GET 'https://xxxx.backendless.app/api/users/userroles' \  
--header 'user-token: 270A5E05-ECE0-41EC-B388-DB590F9D3FAA'

Codeless Reference

user_service_codeless_get_user_roles

Returns a list containing current user roles.

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", and retrieves the current user roles as a list containing string values.

user_service_codeless_example_get_user_roles_example_2

The output will look as shown below after the Codeless logic runs:

user_service_codeless_example_get_user_roles_example_3