Get access_token from the response body of one http request and pass to another http request header
I tried to get access_token from the first http request like below
access_token: {{$.hTTPRequest.body.access_token}}
and passed the access_token for the second http request header
access_token: {{$.hTTPRequest.body.access_token}}
Authorization: Bearer $application.access_token$
Are you using “Custom Authorization” to configure the “first http request” as you noted? If so, you should be able to map this directly in the UI as “access_token” = “access_token”.
In the “second http request” header you should be able to just map this as “Authorization” = “Bearer $application.access_token$”
I’m using custom authorization, I mapped like your suggestion in first http request and passed the second http request same like your suggestion, I’m still getting error. Please see the screen shots.
This is an
internal application, the access_token generating and passing in to second http request in postman correctly with out any 401 errors. where as in IdentityNow getting 401 error.
Manually copy the Bearer token from Postman and paste it into the Web Service connector’s Direct Aggregation HTTP operation. Then run the operation to check if it works as expected.
If it works, proceed to test the same logic within a Workflow HTTP Request. This will help you confirm whether the bearer token is being generated and correctly passed to subsequent HTTP requests. Use Two HTTP request to collect in first and pass in second once, you can validate output while testing and can easily fix the issue.
Using this approach, you can easily troubleshoot any issues related to token generation or transmission.
Considering it’s an “internal” application vs. COTS application, reach out to the application team and coordinate an API testing session with them to see what the application is actually getting for the headers/body. Also ensure the application is truly getting a “bad” authorization vs. something else in the API that just happens to respond with an incorrect error saying “connection refused” (or similar)
@sidharth_tarlapally ,
I’m successfully making test connection, and authentication working correctly, only issue not able to pass access_token in the second http request.
All your suggested steps works correctly in the first step on the WebService connector and 2nd step in the workflow http request.
Where as the issue doesn’t fix on the webservice connector to fetch access_token and pass into the second http request to get access_token dynamically.
I have all the steps in the connector except
schema attribute as “customToken” rather than “access_token”. I know this is not an issue but worth a try.
I tried with customToken rather than access_token, still getting 401 error