I'm trying to invoke an API using scalaj. I need to have a Authorization as type Bearer Token passed with the request. When I try to execute this API using Postman as well as curl, I'm able to get a valid response.
curl -H "Authorization: Bearer <some auth token>" -H 'Accept: application/json' <some url>
But when I try to run it using the scalaj library, it fails to run, giving me 401: Not Authorized
. This is the code I'm trying to run:
val response = Http("https://<my url>")
.headers(Seq("Authorization" -> ("Bearer " + authToken)))
.asString
.body
(PS. authToken
is defined and valid, no doubts there)
Why I'm trying to have Bearer Token is because its mentioned in the docs:
Every request must include the Authorization HTTP header with the value Bearer [access_token]. An access token can be obtained with the /auth/tokens endpoint, and it is used by Product XYZ to identify who you are. Product XYZ negotiates SSL connections using the TLS v1.2 protocol.