Comments (14)
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
from django-rest-framework-social-oauth2.
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()
.add("client_id","confidencial")
.add("client_secret","confidencial")
.add("grant_type", "refresh_token")
.add("refresh_token", tokenRefreshData)
.add("Content-Type", "application/x-www-form-urlencoded")
.build();
from django-rest-framework-social-oauth2.
I discovered the problem, I'm sending requests with Content-Type: application/json
, but apparently the required is Content-Type: application/x-www-form-urlencoded
Why is required x-www-form-urlencoded and not json?
And I suggest you add this requirement in the README 😄
from django-rest-framework-social-oauth2.
@rodolphopivetta thanks for your right answer. :)
from django-rest-framework-social-oauth2.
Show me your request so I can help you out
from django-rest-framework-social-oauth2.
using the URL
http://127.0.0.1:8000/auth/token/
method: POST
Body:
{
"grant_type": "password",
"client_id": "SxOKjAuWdHDw07NIyogYhjOTn6amDVXSG9WjYydn",
"client_secret": "ejvOxEmloOobtB45USCljfASygtXxpOUbQiWxJwE60RLA7rhTSmWNLi3YonCTj5orKq8JDxyiKa66QP5mAoiu8mu57qJeCPmXv689P3PoSeJcb7Va30wI8dyJjSrazMR",
"username": "testuser",
"password": 123
}
from django-rest-framework-social-oauth2.
You are sending an integer instead of a string for the password.
from django-rest-framework-social-oauth2.
Same error as string
{
"grant_type": "password",
"client_id": "SxOKjAuWdHDw07NIyogYhjOTn6amDVXSG9WjYydn",
"client_secret": "ejvOxEmloOobtB45USCljfASygtXxpOUbQiWxJwE60RLA7rhTSmWNLi3YonCTj5orKq8JDxyiKa66QP5mAoiu8mu57qJeCPmXv689P3PoSeJcb7Va30wI8dyJjSrazMR",
"username": "testuser",
"password": "123"
}
from django-rest-framework-social-oauth2.
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"
}
from django-rest-framework-social-oauth2.
Is your Application object set to confidential ?
from django-rest-framework-social-oauth2.
Yes, you can see this in the iPython query above
from django-rest-framework-social-oauth2.
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'
😄
from django-rest-framework-social-oauth2.
I had no idea.
It's probably coming from the oauth toolkit package.
from django-rest-framework-social-oauth2.
@earmc I have the same problem. Did you figure it out ? If yes, how ? Thanks!
from django-rest-framework-social-oauth2.
Related Issues (20)
- Documentation is out of sync HOT 1
- Django rest framework social oauth2 causing unexpected error with Djongo for mongoDB conversion of django app HOT 2
- How can I access "access tokens" of registered users in Backend ? HOT 1
- installing to docker container HOT 1
- Getting error while creating new application. HOT 1
- AppleIdAuth not working HOT 6
- url oauth callback for twitter HOT 1
- Fix simple typo: internaly -> internally HOT 1
- How can I revoke the refresh tokens?
- Your credentials aren't allowed HOT 1
- Refresh Token Error HOT 1
- unsupported_grant_type when trying to refresh token HOT 1
- custom backend not working with convert token api
- Question HOT 10
- Quick fix to enable this package to work with Django 4 and the older versions HOT 1
- why im getting invalid client error while trying to post in postman HOT 2
- I am getting a 401 Error (Unauthorized) and Uncaught (in promise) Error. Same is working fine on PostMan
- How to associate an existing user with multiple social accounts (different emails)? [DRF_SOCIAL_OAUTH2]
- cannot import name 'url' from 'django.conf.urls' HOT 5
- Client ID Error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-rest-framework-social-oauth2.