scalaj / scalaj-http

Simple scala wrapper for HttpURLConnection. OAuth included.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Authentication with bearer token not working

Sparker0i opened this issue · comments

I'm trying to GET an endpoint using curl like this:

curl -H "Authorization: Bearer <some auth token>" -H 'Accept: application/json' <some url>

But while writing the code for the same in scala using scalaj-http library, it does not work:

val response = Http("<that same url>")
    .header("Authorization" , "Bearer " + authToken)
    .header("Accept" , "application/json")
    .asString
    .body

println(response)

Above code piece gives me Invalid authentication token output in the response, while the curl GET request had no such problems

"Invalid authentication token" is a message from the server you're contacting. Guessing that authToken does not have the value that you think it has?