I have done that before but it was not Oauth2.
Original Message:
Sent: 06-14-2022 14:54
From: Shashank Kumar
Subject: Oauth 2 token
@Hazem Farajallah
What's the Authentication Type that you have set for the WebAPI? Is it None or OAuth2?
If you are retrieving the token by calling one of the actions of the WebAPI (and not using the built in functionality of the WebAPI for OAuth2 authentication) then the Authentication Type will have to be set to None.
------------------------------
Shashank Kumar
DX Integrations Partner Consultant
Blue Prism
Singapore
+6581326707
Original Message:
Sent: 06-14-2022 08:44
From: Hazem Farajallah
Subject: Oauth 2 token
Hello Thanks for answering,
I have done it as below i got this error msg now "Internal : Unexpected error Error during Web API HTTP Request
HTTP Status Code: 400
HTTP Response Content: {"error":"invalid_request","error_description":"AADSTS900144: The request body must contain the following parameter: 'grant_type'.\r\nTrace ID: 1efa6a7a-ac67-49fa-97a1-a1d0d4290e00\r\nCorrelation ID: 437de48a-2543-461f-ae2f-0abdadbaab12\r\nTimestamp: 2022-06-14 07:41:29Z","error_codes":[900144],"timestamp":"2022-06-14 07:41:29Z","trace_id":"1efa6a7a-ac67-49fa-97a1-a1d0d4290e00","correlation_id":"437de48a-2543-461f-ae2f-0abdadbaab12","error_uri":"https://login.microsoftonline.com/error?code=900144"}
"
I set the header for applciation/x-www-form-urlencoded and the request body"grant_type=client_credentials&client_id=[XXXXX]&client_secret=[XXXXX]&resource=https://api.prod.digitalchargingsolutions.com/b2bgateway "
------------------------------
Hazem Farajallah
RPA-developer
e-on
Europe/Malmo
Original Message:
Sent: 06-13-2022 17:38
From: Ronan Considine
Subject: Oauth 2 token
Hi Hazem,
I noticed above that in postman the x-www-form-urlencoded option is selected for the body.
www form urlencoded uses a slightly different language which Postman automatically converts for you however BluePrism does not.
What you will need to do it to convert your body from JSON into this new format as Shashank has detailed. Postman allows you to select between JSON and raw text but BluePrism will automatically convert this so you just need to set the body as the text in the following format with appropriate values but without quotation marks.
grant_type=client_credentials&client_id=[XXXXX]&client_secret=[XXXXX]&resource=https://api.prod.digitalchargingsolutions.com/b2bgateway
You will also need the header Content-Type of applciation/x-www-form-urlencoded in the headers section of this call or API in BluePrism.
Here is a similar issue that was faced by another community member where it was resolved following these steps. https://community.blueprism.com/communities/community-home/digestviewer/viewthread?MessageKey=56f84dee-6882-4325-93db-427505fcf9c8&CommunityKey=3743dbaa-6766-4a4d-b7ed-9a98b6b1dd01#bm56f84dee-6882-4325-93db-427505fcf9c8
Hope this helps, reach out if you have any further issues.
------------------------------
Ronan Considine
Senior Business Analyst
Blue Prism
Original Message:
Sent: 06-13-2022 12:33
From: Hazem Farajallah
Subject: Oauth 2 token
Hi kumar, thanks for answering
i have it stright fowrad i send the parameter in the body ,
Yes its give me 401, with all token from BP.
------------------------------
Hazem Farajallah
RPA-developer
e-on
Europe/Malmo
Original Message:
Sent: 06-13-2022 11:38
From: Shashank Kumar
Subject: Oauth 2 token
HI Hazem,
By wrong token, do you mean mean the subsequent API calls gives you 401 with a token that was generated using BluePrism?
If you can post a snapshot of POSTMAN configuration vs BluePrism configuration, we can compare and comment on what's the potential issue.
------------------------------
Shashank Kumar
DX Integrations Partner Consultant
Blue Prism
Singapore
+6581326707
Original Message:
Sent: 06-13-2022 10:14
From: Hazem Farajallah
Subject: Oauth 2 token
Hello ALL,
We have few APIs need to authinticate via Ouath2 ,
I have set all the parameter ,client id , secret.....etc,
BP always genrate worng token when i try it on Postman!
If i do same request in post man it works perfictly same parameters!
is this happend to anyone ? any ideas?
------------------------------
Hazem Farajallah
RPA-developer
e-on
Europe/Malmo
------------------------------