Reputation: 5493
I am using Django Rest Framework Token authentication and if i do curl http://localhost:8000/api/v1/users/?format=json -H 'Authorization: Token 0a813fdcd3f8846d6fa376f2592bbc678b0b8e85'
everything works fine.
But when i try to achieve that with Postman chrome client it nothing happens. What am i doing wrong??
Upvotes: 34
Views: 28544
Reputation: 788
After get access token from http://127.0.0.1:8000/accounts/login/
such this :
{
"email": "[email protected]",
"tokens": {
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTY2NjI2NTAxMSwiaWF0IjoxNjY2MTc4NjExLCJqdGkiOiJjZWM3MzJmNDZkMGE0MTNjOTE3ODM5ZGYxNzRiNzMxZCIsInVzZXJfaWQiOjcwfQ.5Rd25s6msp72IHyU1BxE4ym24YIEbhyFsBdUztGXz0I",
"access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjY2MjY1MDExLCJpYXQiOjE2NjYxNzg2MTEsImp0aSI6IjgyOWFmZGE5MWY2ODRhNDZhMDllZGMzMmI0NmY0Mzg5IiwidXNlcl9pZCI6NzB9.TYhi0INai293ljc5zBk59Hwet-m9a1Mc1CtA56BEE_8"
},
"id": 70
}
copy content of "access" key in response, then in post man in Headers add new item by key : Authorization
and value such this:
Bearer eyJ0eXAi....
that eyJ0eXAi.... is value of access key.
then send the request.
Upvotes: 0
Reputation: 117
After Specifying Authorization and Token value try to add the token in an environment so that every time you don't have to copy the token value.
Upvotes: 0
Reputation: 51
For the new version of postman it is necessary to choose Auth 2 type authentication in the left panel, then in the right panel, specify the DRf key which is "Token" and in the value the token itself.
Upvotes: 3
Reputation: 541
In addition to the above answer, make sure to enable "Follow Authorization header" under setting (See below screenshot)
Upvotes: 0
Reputation: 41719
You are setting the header to Authorization: Token
when it really should just be Authorization
. The header is actually just Authorization
, but the value is Token [token_string]
, where [token_string]
is the authorization token that you have obtained.
Upvotes: 47