DEV Community

loading...

Discussion on: Developing token authentication using ASP.NET Core

Collapse
gustavosg profile image
Gustavo Souza Gonçalves

When i pass the Authorization Bearer in header, it gives me this error:
The header name format is invalid.

This is how i'm passing it:

client.DefaultRequestHeaders.Add("Authorization:Bearer", json.accessToken);

where client is a HttpClient variable and json.accessToken is the value of the token.

Thread Thread
xgabba profile image
Daniel E.

Another approach..
If you download the tool Postman you can easily check how this works.
After you revieced your token, you just have to put into Header:
Key: Authorization
Value: Bearer YOUR_TOKEN
including the whitespace between Baerer and your token!

Thread Thread
forestmarie profile image
Forest Marie

I get nothing but 401s using this very approach in Postman.

Forem Open with the Forem app