Hello everyone, I have been trying for quite some time to get a RESTapi to work, which needs to connect and disconnect from the API with each request. To do this, we need to add a Token ID to each request, obtained with the first request, and pass it in the Header.
After some research, I came to understand that I must go through the OnBeforeRequest/OnAfterRequest options... but I can't figure out how to pass my token in the header of subsequent requests.
Here is what I need to accomplish:
1. Login to API 2. The server return in body the access token : }“access_token”: “”,“expires_in”: 3600,“token_type”: “Bearer”,“scope”: “api”}
3. Add the token in the header of all the subsequent requests : Authorization : Bearer + access_token
4. Logout
Thank you for your help!
Hi Kevin,
Try to use the AddHeader built in server action from the HTTPRequestHandler module. I guess this should help.
Please let me know if this works...
Regards,
Prakhar Sharma
Hi,
In OnBeforeRequest handler you can append the header to headerlist of request like this:
Pramod
Hi Kevin Desbiens,
Please check the below url for step by step guide how you can customize your header for token authentication.
https://success.outsystems.com/documentation/11/extensibility_and_integration/rest/consume_rest_apis/simple_customizations/
Hope this helps.
Manish Jawla