72
Views
4
Comments
Consume API REST with OAuth2 - dynamic client secret?

Is it possible to provide dynamically the client secret to the built-in OAuth2 API authentication? As I see it, you set the password in Service Center.

Attached are the Studio API mapping screen and the Service Center.



api-oauth2-secret.png
api-oauth2-sc.png
2021-03-30 13-44-25
Balaji Ravikumar

Hi Ricardo Campos,

It’s not feasible to pass dynamic Client ID and Client Secret. However, if that’s not an issue, you can create multiple API consumers with distinct Client IDs and Client Secrets for each.

Thanks

Balaji


2024-08-10 14-49-39
Dinh Nhat Thi

Hi guy, I have some solutions for your case:

Solution 1: Go to Service Center choose the Consumed REST API you want in Intergration Tab, then fill in credentials information like this: 

Solution 2: Using OnBeforeRequest Action. You should select Client authentication is Send client credentials in body. Then in the OnBeforeRequest you modify RequestText like this: 

 CustomizedRequest.RequestText = "{ 

    client_id: your_client_id,

   client_secret: your_client_secret

}"


Follow this link: https://success.outsystems.com/documentation/11/integration_with_external_systems/rest/consume_rest_apis/use_oauth_2_0_client_flow_authorization_in_consumed_rest_api_web_services/

UserImage.jpg
Ricardo Campos

Hi, Dinh! Thanks for the answer.

Unfortunatelly, the OnBeforeRequest action is not called for the OAuth request, but only for the mapped API request. So, I cannot act before the OAuth authentication. This test I had made with no success.

Regards,
Ricardo.

2021-03-30 13-44-25
Balaji Ravikumar

Hi Ricardo,

How many dynamic client id and client secret you have for oauth2.

Thanks 

Balaji

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.