Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

394
Vistas
Django OAuth2 unsupported_grant_type

I'm trying to send a request with django to get an access_token from my api using OAuth2. I'm executing this code :

data = {'username': 'admin', 'password': '123123', 'grant_type': 
'password','client_id': 'xxx','client_secret': 'xxx'}
headers = {'content-type': 'application/x-www-form-urlencoded'}
r = requests.post(url, data=data, headers=headers)

When I send this request I get this error :

{'error': 'unsupported_grant_type'}

Thanks for your help !

about 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

If anyone is interested the correct request was :

    payload = "grant_type=password&client_secret=xxx&client_id=xxx&username=username&password=password"
    headers = {
        'content-type': "application/x-www-form-urlencoded",
        'cache-control': "no-cache",
    }

    response = requests.request("POST", url, data=payload, headers=headers)
about 4 years ago · Santiago Trujillo Denunciar

0

If you don't want to encode data in url, you can put this in your settings.

OAUTH2_PROVIDER = {                                                                                                                                                                      
    'OAUTH2_BACKEND_CLASS': 'oauth2_provider.oauth2_backends.JSONOAuthLibCore',                                                                                                          
}
about 4 years ago · Santiago Trujillo Denunciar

0

I had the same problem and later I found that the grant type should be a string.

payload = {'grant_type': 'refresh_token', 'refresh_token': refresh_token}
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda