Git Product home page Git Product logo

Comments (14)

rodolphopivetta avatar rodolphopivetta commented on June 19, 2024 4

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.

earmc avatar earmc commented on June 19, 2024 3

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.

rodolphopivetta avatar rodolphopivetta commented on June 19, 2024 1

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.

hustzoujia avatar hustzoujia commented on June 19, 2024 1

@rodolphopivetta thanks for your right answer. :)

from django-rest-framework-social-oauth2.

PhilipGarnero avatar PhilipGarnero commented on June 19, 2024

Show me your request so I can help you out

from django-rest-framework-social-oauth2.

rodolphopivetta avatar rodolphopivetta commented on June 19, 2024

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.

PhilipGarnero avatar PhilipGarnero commented on June 19, 2024

You are sending an integer instead of a string for the password.

from django-rest-framework-social-oauth2.

rodolphopivetta avatar rodolphopivetta commented on June 19, 2024

Same error as string

{
    "grant_type": "password",
    "client_id": "SxOKjAuWdHDw07NIyogYhjOTn6amDVXSG9WjYydn",
    "client_secret": "ejvOxEmloOobtB45USCljfASygtXxpOUbQiWxJwE60RLA7rhTSmWNLi3YonCTj5orKq8JDxyiKa66QP5mAoiu8mu57qJeCPmXv689P3PoSeJcb7Va30wI8dyJjSrazMR",
    "username": "testuser",
    "password": "123"
}

from django-rest-framework-social-oauth2.

rodolphopivetta avatar rodolphopivetta commented on June 19, 2024
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.

PhilipGarnero avatar PhilipGarnero commented on June 19, 2024

Is your Application object set to confidential ?

from django-rest-framework-social-oauth2.

rodolphopivetta avatar rodolphopivetta commented on June 19, 2024

Yes, you can see this in the iPython query above

from django-rest-framework-social-oauth2.

rodolphopivetta avatar rodolphopivetta commented on June 19, 2024
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.

PhilipGarnero avatar PhilipGarnero commented on June 19, 2024

I had no idea.
It's probably coming from the oauth toolkit package.

from django-rest-framework-social-oauth2.

yannbu avatar yannbu commented on June 19, 2024

@earmc I have the same problem. Did you figure it out ? If yes, how ? Thanks!

from django-rest-framework-social-oauth2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.