angel
angel

Reputation: 104

django rest framework OAuth2 Toolkit

i use django rest framework and OAuth2 Toolkit in my django backend app. I registered users in django admin site. Whne i try to get access token with CURL for user i get error:

{"error":"invalid client"}. 

my curl request is bellow:

curl -X POST -d "client_id=MY_CLIENT_ID&client_secret=MY_CLIENT_SECRET&grant_type=password&username=myuser&password=mypass" http://localhost:8000/o/token/

Upvotes: 0

Views: 902

Answers (2)

angel
angel

Reputation: 104

Thank you fo your help I solve my problem. My right curl request is bellow:

curl -X POST -d "grant_type=password&username=USERNAME&password=PASSWORD" --user "CLIENT_ID:CLIENT_SECRET" 

Upvotes: 0

Lee
Lee

Reputation: 859

Do you have the right secret and id and/or the right grant-type?

1) Go to <yoursite>/admin and login with your admin account

2) Go to <yoursite>/o/applications and choose your application

Now you can see your secret, id and grant type(should be 'password'). Also have a look at the client type(should be 'confidential')

Upvotes: 1

Related Questions