2

I have created an endpoint localhost:8000/getauthtoken to generate the authentication token.

The curl command that i am using to get the authentication token is:

curl --request POST --url localhost:8000/getauthtoken --header 'content-type: application/json' --data '{"username":"admin", "password":"admin123"}' 

But i am getting

{"password":["This field is required."],"username":["This field is required."]} 

But in the command i am passing both username and password

As per the DRF documentation http://www.django-rest-framework.org/api-guide/authentication/ this is the correct way.

1
  • It seems to be correct. Are you able to register new users? Commented Jun 19, 2016 at 8:35

1 Answer 1

5

Use httpie (available on pypi) Then follow this on terminal:

Http post your_ip:your_port/your_authresource/ username='' password='' 

Or you can try that in Curl in right way:

curl -X POST http://localhost:8000/api-token-auth/ -d "password=aaaaa&username=user" 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.