33

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??

enter image description here

psychok7
  • 5,373
  • 9
  • 63
  • 101
  • does removing format=json on the end fix anything it seems unecessary if postman is already sending the content-type in the headers. – Chris Hawkes Oct 28 '14 at 19:41

5 Answers5

46

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.

Kevin Brown-Silva
  • 40,873
  • 40
  • 203
  • 237
  • 3
    Make sure your value is `Token` followed by a space, followed by the actual token as specified in this answer (which is correct). – a2f0 Feb 12 '18 at 02:18
3

enter image description hereFor 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.

cscthian
  • 41
  • 2
0

In addition to the above answer, make sure to enable "Follow Authorization header" under setting (See below screenshot) enter image description here

Husam Alhwadi
  • 383
  • 3
  • 11
0

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.

Naveen Pandia
  • 107
  • 13
0

After get access token from http://127.0.0.1:8000/accounts/login/

such this :

{
    "email": "user@example.com",
    "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.

enter image description here

then send the request.

Amirio
  • 628
  • 1
  • 6
  • 12