I am currently using retrofit within an android app, and okhttp client.
When signing my request headers with the auth token using the required format
"Bearer " I get an illegalargumentexception from okhttp.
Removing the space between “Bearer” and the “” resolves this issue, but now my requests into the api are failing with a 403 (UnAuthorized).
Has anyone faced this before ?
I never used retrofit, but the value of the Authorization header should be Bearer+[Token]
where the +
represents an white space. If you’re trying to set it to just Bearer+
then it does not seem correct.
In addition, if you haven’t done so already you should check: android - Retrofit2 Authorization - Global Interceptor for access token - Stack Overflow
Thanks for your reply. I am adding the white space as outlined in the docs.
The stackoverflow link is exactly what I am doing in my current code, but it made me realize i was setting the token as the key, and the key as the value.
Issue is now resolved.