New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unsupported_grant_type #56
Comments
Show me your request so I can help you out |
using the URL
method: POST Body: {
"grant_type": "password",
"client_id": "SxOKjAuWdHDw07NIyogYhjOTn6amDVXSG9WjYydn",
"client_secret": "ejvOxEmloOobtB45USCljfASygtXxpOUbQiWxJwE60RLA7rhTSmWNLi3YonCTj5orKq8JDxyiKa66QP5mAoiu8mu57qJeCPmXv689P3PoSeJcb7Va30wI8dyJjSrazMR",
"username": "testuser",
"password": 123
} |
You are sending an integer instead of a string for the password. |
Same error as string {
"grant_type": "password",
"client_id": "SxOKjAuWdHDw07NIyogYhjOTn6amDVXSG9WjYydn",
"client_secret": "ejvOxEmloOobtB45USCljfASygtXxpOUbQiWxJwE60RLA7rhTSmWNLi3YonCTj5orKq8JDxyiKa66QP5mAoiu8mu57qJeCPmXv689P3PoSeJcb7Va30wI8dyJjSrazMR",
"username": "testuser",
"password": "123"
} |
In [1]: from oauth2_provider.models import Application
In [2]: a = Application.objects.get(id=1)
In [3]: a.client_id
Out[3]: u'SxOKjAuWdHDw07NIyogYhjOTn6amDVXSG9WjYydn'
In [4]: a.client_secret
Out[4]: u'ejvOxEmloOobtB45USCljfASygtXxpOUbQiWxJwE60RLA7rhTSmWNLi3YonCTj5orKq8JDxyiKa66QP5mAoiu8mu57qJeCPmXv689P3PoSeJcb7Va30wI8dyJjSrazMR'
In [5]: a.client_type
Out[5]: u'confidential'
In [6]: a.authorization_grant_type
Out[6]: u'password'
In [7]: from users.models import CommonUser
In [8]: c = CommonUser.objects.all().first()
In [9]: c.set_password("123")
In [10]: c.username
Out[10]: u'roger_freeman'
In [11]: c.save() In postman: URL: http://127.0.0.1:8000/auth/token/ Method: POST {
"client_id": "SxOKjAuWdHDw07NIyogYhjOTn6amDVXSG9WjYydn",
"client_secret": "ejvOxEmloOobtB45USCljfASygtXxpOUbQiWxJwE60RLA7rhTSmWNLi3YonCTj5orKq8JDxyiKa66QP5mAoiu8mu57qJeCPmXv689P3PoSeJcb7Va30wI8dyJjSrazMR",
"username": "roger_freeman",
"password": "123",
"grant_type": "password"
} Response: {
"error": "unsupported_grant_type"
} |
Is your Application object set to confidential ? |
Yes, you can see this in the iPython query above |
In [1]: from oauth2_provider.models import Application
In [2]: a = Application.objects.get(id=1)
In [5]: a.client_type
Out[5]: u'confidential' 😄 |
I discovered the problem, I'm sending requests with Why is required x-www-form-urlencoded and not json? And I suggest you add this requirement in the README 😄 |
I had no idea. |
I finally resolve my problem adding this in the settings: OAUTH2_PROVIDER = {
'OAUTH2_BACKEND_CLASS': 'oauth2_provider.oauth2_backends.JSONOAuthLibCore',
} Thanks for your attention @PhilipGarnero and consider adding this information in the instructions |
good night everbody. I whould like know if someone have problem with made refresh token. I have this answer "unsupported_grant_type" but when i try to post request a refresh token. I appreciate if someone can suggest me some solution this is my body request: RequestBody requestBody = new FormEncodingBuilder()
|
@earmc I have the same problem. Did you figure it out ? If yes, how ? Thanks! |
@rodolphopivetta thanks for your right answer. :) |
I'm trying to authenticate an user following the instructions in the README, but when I request a token for an user, I receive:
In my application the "Authorization grant type" field is "password" value:
What I'm doing wrong?
The text was updated successfully, but these errors were encountered: