Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django OAuth Toolkit invalid_grant error

I have a bit of a problem, I have a django application that is using Django OAuth Toolkit and I can't get the access token from the server when using Authorization Code flow. Implicit flow works fine. I haven't find anything regarding my problem on stack so I'm really sorry if this is a duplicate of another question.

I can authorize with this url and get the request come back, if i understand it correctly the request token is past in the code param.

http://mydomain.se/o/authorize?scope=read+write&state=kalle&redirect_uri=mycallbakurls&response_type=code&client_id=myclientid

when i then try to do a post to http://mydomain.se/o/token/ with:

grant_type = authorization_code
code = code from authorize call
client_id = my clientId
client_secret = my client secret
redirect_uri = my callback url 

i get "error" : "invalid_grant" back.

Can someone please point me in the right direction what the problem can be?

Best regards Markus

like image 892
Vaionixx Avatar asked Dec 02 '22 15:12

Vaionixx


1 Answers

This can happen if the code is expired. They expire pretty quickly by default. You can look up your code in the Django admin under Grants and change the expiration date to far in the future.

like image 110
Jess Avatar answered Dec 26 '22 18:12

Jess