Authentication for Rest Client Data Integration
In the data integration scenario, Rest Client is an important tool for interacting with RESTful APIs. Correct configuration of the authentication mechanism for Rest Client is key to ensuring data security and interaction stability. The following are four common authentication modes:
- No authentication (NONE)
If the data source APIs do not require authentication, you can select this mode. It is applicable to public APIs or internal secure network environments that do not require additional authentication.
- Basic authentication (BASIC_AUTH)
- Add the Authorization field to the request header.
- Combine the username and password into a string in username:password format.
- Encode the string using Base64.
- Add Basic followed by the encoded string to the Authorization header of the HTTP request. The format is Authorization: Basic base64(username:password).
- For example, if the username is user, the password is pass, and the Base64-encoded string is dXNlcjpwYXNz, the request header is Authorization: Basic dXNlcjpwYXNz.
- Replace the username and password.
- When configuring the request header or body, you can use placeholders #username and #password.
- When the request is sent, these placeholders are replaced with the actual username and password.
- Add the Authorization field to the request header.
- Token authentication (TOKEN_AUTH)
The authentication mode (TOKEN_AUTH) is implemented as follows:
1. Add the Authorization field to the request header.
- Add the token value to the Authorization header of the HTTP request. The format is Authorization: Bearer #token.
#token is a placeholder that indicates the token value.
- For example, if the token value is abc123, the request header is Authorization: Bearer abc123.
2. Replace a token.
- Add the token value to the Authorization header of the HTTP request. The format is Authorization: Bearer #token.
- OAuth 2.0 (OAUTH_CODE_GRANT)
This mode works as follows:
- Obtain an authentication token through the authentication configuration.
- Authentication URL: API URL for obtaining an authentication token
Example: https://example.com/oauth/token
- Authentication request method: HTTP method used to request an authentication token
- Authentication request header: request header, which may contain the authentication account, password, or other necessary information
{ "Content-Type":"application/json", "username":"#authUsername", "password":"#authPassword" } - Authentication request body: request body, which contains the authentication account and password
{ "username":"#authUsername", "password":"#authPassword" } - Authentication account and password: account and password for authentication
#authUsername and #authPassword are variables.
- Authentication token: defines how to extract an authentication token from the response of the authentication API.
The authentication token can be obtained from the response body. The following is an example:
{ "code": 200, "data": { "access_token": "xxx", "expired": 1000 } }Configurable authentication token:
{ "NAME": "Authorization", "VALUE": "#response.data.access_token" }The authentication token can also be obtained from the response header. The following is an example:
{ "x-token": "xxx"}Configurable authentication token:
{ "NAME": "Authorization", "VALUE": "#header.x-token" }
Figure 3 Parameters
- Authentication URL: API URL for obtaining an authentication token
- Use an authentication token.
- The authentication token is automatically added to the request header.
#{Authentication token.Name}: #{token}#{Authentication token.Name} is the name of the authentication token, and #{token} is the authentication token that can be dynamically replaced.
For example, the authentication token is as follows:
{ "NAME": "Authorization", "VALUE": "#response.data.access_token" }The following information is automatically added to the request header:
Authorization: #{token} - Dynamic token replacement: The placeholder #{token} in the URL or request body is replaced with the actual authentication token when the request is sent.
For example, set the URL to https://xxx.com/prefix/#{token}.
Alternatively, replace the placeholder in the request body:
{ "token": "#{token}"}
- The authentication token is automatically added to the request header.
- Obtain an authentication token through the authentication configuration.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot

