Using a service account to get users
Use the service account and its token you created in previous sections to get users under your tenant.
The API to be used is https://api.<env>.cloud.talend.com/account/users
.
Before you begin
- Ensure that the service account to be used to issue API calls has the Users - Manage permission. The ID of this permission is
TMC_USER_MANAGEMENT
.
About this task
In this section, the following API call is issued:
method: GET
endpoint: https://api.<env>.cloud.talend.com/account/users
headers: {
"Authorization": "Bearer <service_account_token>"
}
It is implemented in Talend API Tester for demonstration purposes.
In Talend API Tester, you can use an expression builder to dynamically retrieve the service account token from its related API request.
Procedure
- Select GET from the Method list and in the field aside, enter the user management endpoint to be used:
https://api.<env>.cloud.talend.com/account/users
-
Click Add header and in the name field that is displayed, enter
Authorization
and in the value field, enterBearer
and the service account access token in plain text or click the to build a dynamic expression. Enter a whitespace to separateBearer
and the token.Since you need to renew the token once the current one expires, it is recommended to use an expression to enable this API request to dynamically use the latest token once it is renewed by the token API request.
In Talend API Tester, you can use the expression builder to write the expression. Note that the token API request must have been saved in your repository. In the previous section, this API request was saved and named as
Renew the SAT
.This makes the value of
Authorization
look like this:Bearer ${"service-account 2021"."Service Account Token scenario"."Renew the SAT"."response"."body"."access_token"}
- Send and save the request.
Results
A user list is returned with the status code 200.