Skip to content

Commit

Permalink
add-rest-api-client-credentials-auth-component (#1403)
Browse files Browse the repository at this point in the history
  • Loading branch information
HannaTrotsenko authored Oct 17, 2024
1 parent abc157a commit 7e11327
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,24 @@ description: A component that can make REST calls while using OAuth2 Client Cred
icon: rest-api-client-credentials-auth-component.png
icontext: Rest API OAuth2 Client Credentials Component
category: rest-api-client
updatedDate: 2024-06-03
ComponentVersion: 1.2.0
updatedDate: 2024-10-17
ComponentVersion: 1.3.0
---

## Table of Contents

* [General information](#general-information)
* [Description](#description)
* [Environment variables](#environment-variables)
* [Credentials](#credentials)
* [Actions](#actions)
* [HTTP request](#http-request)
* [Known Limitations](#known-limitations)

## General information

### Description

Component that can make REST calls while using `OAuth2` Client Credentials Auth Grant Type.
Component that can make REST calls while using OAuth2' Client Credentials Auth Grant Type.

More details about OAuth2 Client Credentials Auth Grant Type:

Expand All @@ -27,7 +36,6 @@ More details about OAuth2 Client Credentials Auth Grant Type:
Component does not use any environment variables

## Credentials

* Token URL (required): Full URL from which to retrieve the access token
* Username (required)
* Password (required)
Expand All @@ -36,44 +44,39 @@ Component does not use any environment variables
* Additional Properties (optional): Comma separated list of additional properties. Each property should have key and value with `:` (example: `client_id:123`)
* Tokens (JSON String, optional): Place to store access tokens & other received metadata (e.g. expiry time).

> Example: `"{\"access_token\":\"access_token_value\",\"token_type\":\"bearer\",\"expires_in\":86400,\"tokenExpiryTime\":\"2021-11-11T23:18:00.470Z\"}"`
## Triggers

This component has no trigger functions. This means it will not be accessible to
select as a first component during the integration flow design.
Example: `"{\"access_token\":\"access_token_value\",\"token_type\":\"bearer\",\"expires_in\":86400,\"tokenExpiryTime\":\"2021-11-11T23:18:00.470Z\"}"`

## Actions

### HTTP request

#### Config Fields

* **Error Tolerance** (dropdown, required): Determines behavior for when an erroneous HTTP code is received. Options are as follows:
* Error Tolerance (dropdown, required): Determines behavior for when an erroneous HTTP code is received. Options are as follows:
* **No Errors Tolerated**: Any HTTP status code >= 400 should result in an error being thrown
* **Only Not Found Errors Tolerated**: HTTP status codes of 404, 410 or similar should result in a message being produced with the status code and the HTTP reponse. All other error codes should result in an error being thrown.
* **None**: Regardless of the HTTP error code, the component should produce an outbound message with the status code and the HTTP response.
* **Manual**: A range of error codes to throw errors on can be configured via the message input.
* **Request timeout in sec** (number, optional): How long to wait for a response from the remote server before throwing a timeout error (this timeout value also applies to the token request call). *Default - 60sec*.
* **Maximum response size in bytes** (number, optional): You can limit here maximum size of the response body in bytes to prevent OOM errors. Default and maximum is 20971520 bytes (20MB).
* **Rebound Selected Codes**: Error codes to rebound can be configured via the message input. If received code doesn't match with provided, error will be thrown.

#### Input Metadata
* Request timeout in sec (number, optional): How long to wait for a response from the remote server before throwing a timeout error (this timeout value also applies to the token request call). Default - 60sec
* Maximum request size in bytes (number, optional): You can limit here maximum size of the request body in bytes to prevent OOM errors. Default and maximum is 20971520 bytes (20MB)
* Maximum response size in bytes (number, optional): You can limit here maximum size of the response body in bytes to prevent OOM errors. Default and maximum is 20971520 bytes (20MB)

#### Input Metadata
* Url (string, required): Path of the resource relative to the URL base. If there is no URL base, or if then this should be treated as the full URl.
* Method (string enum, required): HTTP Verb for the request.
* HTTP headers (object, optional): HTTP headers to attach to the request
* Request Body (object, optional): Body of the request to send
* If **Error Tolerance** is **Manual**:
* HTTP Codes to throw errors (array of error ranges, optional default to `[]`): A double array with a list of ranges of HTTP response codes to throw errors upon receiving Use a syntax that matches retry-axios. Example: `[[400, 403], [405,599]]` - Throw errors on all errors apart from 404.
If array is empty, no error would be thrown, produce an outbound message with the status code and the HTTP response.
If array is empty, no error would be thrown, produce an outbound message with the status code and the HTTP response.
* If **Error Tolerance** is **Rebound Selected Codes**:
* HTTP Codes to rebound (string, required): Coma separated list of the codes to rebound, example: `404, 401`. If you put here `*` all codes will be rebounded. If the rebound code doesn’t match the response code, an error will be thrown.


#### Output Metadata

* Status Code (integer, required): HTTP status code of the request
* HTTP Headers (object, optional): HTTP headers of the response
* Response Body (object, optional): JSON representation of the response body from the request

## Known Limitations

Please note that for the functionality to save and update the token to work correctly, the platform user must have `workspaces.credential.edit` permission (see [API docs]({{site.data.tenant.apiDocsUri}}/v2#/credentials/patch_credentials__credential_id_)).
Please note that for the functionality to save and update the token to work correctly, the platform user must have `workspaces.credential.edit` permission (see elastic.io [API docs](https://api.elastic.io/docs/v2/#update-a-credential)).
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ description: Technical Notes for the Rest API OAuth2 Client Credentials componen
icon: rest-api-client-credentials-auth-component.png
icontext: Rest API OAuth2 Client Credentials Component
category: rest-api-client
updatedDate: 2024-06-03
ComponentVersion: 1.2.0
updatedDate: 2024-10-17
ComponentVersion: 1.3.0
---

## Changelog

### 1.3.0 (october 17, 2024)
* Updated API request handling to use `axiosReqWithRetryOnServerError` from `component-commons-library`
* Added new option `Rebound Selected Codes` to configuration field `Error Tolerance` in `HTTP request` action
* Update Sailor version to `2.7.3`
* Update component-commons-library version to `3.2.1`

### 1.2.0 (June 03, 2024)

* Added `Maximum response size in bytes` configuration field to `HTTP request` action.
Expand Down

0 comments on commit 7e11327

Please sign in to comment.