APIGW Custom Extension Policy for external endpoint to get access token and pass into main request header

Can any one assist me on below case?
how can I pass the bearer token authorization in main request? I applied custom extension policy in request processing stage and applied the external endpoint to get the access token. In response section I tried to add the authorization header with bearer token in main request header but i getting the 401(not authorized) https status.

Hi Zeeshan,
Are you trying to pass the authorization header with bearer token to the native service? You can add the header information as part of request processing in the request processing Custom Extension. Do let me know if it works.


I tried but no luck.

Hi @zeeshan.tufail,

I see you have two different variables in the transformation value in the response processing section. Where is the value for ${AccessToken} coming from? Can you try the below syntax for the Transformation value:

Bearer ${response[customExtension].payload.jsonPath[$.access_token]}

where “access_token” is the json attribute within custom extension’s response containing the access token that you would like to use.

Thanks guy. Issue has been resolved a week ago.