cancel
Showing results for 
Search instead for 
Did you mean: 

Oauth 2 token

HazemFarajallah
Level 4

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
------------------------------

10 REPLIES 10

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
------------------------------

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
------------------------------

hi this is directly in the body!



------------------------------
Hazem Farajallah
RPA-developer
e-on
Europe/Malmo
------------------------------

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-432...

Hope this helps, reach out if you have any further issues.

------------------------------
Ronan Considine
Senior Business Analyst
Blue Prism
------------------------------
Ronan Considine Senior Business Analyst Blue Prism

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
------------------------------

@HazemFarajallah

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
------------------------------

@Shashank Kumar this should be Ouath2 to return a token for other API,s   So up i set it to none so i can retrive the token and send it from the process to the other web API.

I have done that before but it was not Oauth2.

​​



------------------------------
Hazem Farajallah
RPA-developer
e-on
Europe/Malmo
------------------------------

Hi Ronan,

What is this format called?
"grant_type=client_credentials&client_id=[XXXXX]&client_secret=[XXXXX]&resource=https://api.prod.digitalchargingsolutions.com/b2bgateway"

how can i convert below JSON code to the one which BP can accept for applciation/x-www-form-urlencoded?

tradeReqJson:[{"accountName":"XXXX","securityID":"xxxxxxx","securityFilingVal":"xxxxxx","accountFilingVal":"xxxx","ruleID":xxxxx,"processIdentifier":"N","toDateStr":"xxxxx"},{"accountName":"XXXXX","securityID":"xxxxx","securityFilingVal":"xxxxxx","accountFilingVal":"xxxx","ruleID":xxxxx,"processIdentifier":"N","toDateStr":"xxxxx"}]

------------------------------
Meng Yu
Process Solution Senior Analyst II
FIL
Asia/Hong_Kong
------------------------------

Hi Meng,

The format is just raw text and you would not have any quotation marks when posting the body using x-www-form-urlencoded.

Conversion would be for 1 line of  the tradeReqJson

accountName=XXXX&securityID=xxxxxxx&securityFilingVal=xxxxxx&accountFilingVal=xxxx&ruleID=xxxxx,processIdentifier=N&toDateStr=xxxxx

I am unsure how you would send an array of more than one line with urlencoded, you will also need to ensure that all the headers are correct using the thread above and the other thread mentioned.

Best Regards,



------------------------------
Ronan Considine
Senior Business Analyst
Blue Prism
------------------------------
Ronan Considine Senior Business Analyst Blue Prism