How to add token authorization to a API request using WSO2 APIM

54 Views Asked by At

I have API request which looks something like this:

curl --location 'http://199.3x.xx.3x:4041/country/usa' \
--header 'Content-Type: application/json' \
--header 'language: english' \
--header 'culture: /' \
--data '{
 "info": [
   {
     "city":   "newyork"
}'

I want to add authorisation in the header.

--header 'Authorisation: Bearer asdasbdaudsaldhjsaa'

I want to add token authorisation using WSO2 APIM publisher and devportal. Can you please tell me the steps that should be followed to achieve this.

I tried to put http://199.3x.xx.3x:4041/ as endpoint, country as context and usa as devices.

And I added header and body in the Post resources.

But this does not work.

1

There are 1 best solutions below

0
On

Assuming that you need to send the Authorization header to your backend, you can follow the documentation[1] to achieve this. What you have to basically do here is send the actual authorization header under a different header and it will be replaced automatically by the APIM gateway when the request is processed.

[1] - https://apim.docs.wso2.com/en/3.2.0/learn/api-gateway/message-mediation/passing-a-custom-authorization-token-to-the-backend/