Hi,
Today, I need to send a GET request using an authentication bearer. I enter the token for the bearer in Parameter 150 but it looks like my HTTP Session below doesn't sent the authorization information. From the provider, the request in curl should be formated as follow:
curl - -location - -request GET 'https://api-knt.skylogic.com/ext/api/v1/whs/services' \ --header 'Authorization: Bearer <MY-ACCESS-TOKEN>' - -header 'Accept: application/json'
So, the problem I have here is how to implement the "--header 'Authorization: Bearer <MY-ACCESS-TOKEN>'"? Here follow my code for the HTTP Sessions. Session id="1" works fine and I put the authorization parameters as parameter as kind advised by Laurens. So tried something similar in Session id="2" which is supposed to sent my GET:
<HTTP>
<Session id="1" name="Get Token">
<Connection id="1" name="Get Token">
<Request verb="POST" url="/ext/api/v1/whs/oauth2/token">
<Parameters>
<Parameter key="grant_type">client_credentials</Parameter>
<Parameter key="client_id" pid="152" />
<Parameter key="client_secret" pid="153"/>
</Parameters>
<Headers>
<Header key="Content-Type">application/x-www-form-urlencoded</Header>
</Headers>
</Request>
<Response statusCode="100">
<Content pid="200" />
</Response>
</Connection>
</Session>
<Session id="2" name="Get Status">
<Connection id="2" name="Get Status">
<Request verb="GET" url="/ext/api/v1/whs/services/200396/subscriptions">
<Parameters>
<Parameter key="Authorization: Bearer" pid="150"/>
</Parameters>
</Request>
<Response statusCode="101">
<Content pid="201" />
</Response>
</Connection>
</Session>
</HTTP>
However, the answer I receive in this case is "Error 401, unauthorized access", as if the "<Parameter key="Authorization: Bearer" pid="150"/>" was not sent or wrongly formeted, maybe. So I will greatly appreciate your advice on this 🙂
One issue that I'm noticing is the fact that Bearer is part of your header key which should actually be part of your header value. So the correct way of configuring this in the session would be:
<Header key="Authorization" pid="150"/>
And then prepend Bearer to the value you currently have stored in parameter 150.
So the content should look like Bearer <MY-ACCESS-TOKEN>
Hi Donimique,
I think the item should be added to the headers in this case for session 2 instead of to the parameters section as that would add it to the URL in case of a GET.
Something like:
<Headers>
<Header key="Accept">application/json</Header>
<Header key="Authorization" pid="150"></Header>
</Headers>
With parameter 150 then containing the value "Bearer <MY-ACCESS-TOKEN>"
Hi Laurens, Jeroen,
I did exactly what you advised and it works fine, thank you so much. So we can say this issue is now solved.