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

794
Vistas
OAuth - Google API unsupported_grant_type

I was already checking other threads with the same error and still couldn't fix it.

So here is my PHP code:

$data = [
        "client_id" => "id-here",
        "client_secret" => "secret-here",
        "refresh_token" => "refresh-token-here",
        "grant_type" => "refresh_token"
    ];
    $ch = curl_init( 'https://www.googleapis.com/oauth2/v4/token' );
    curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/x-www-form-urlencoded'));
    curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );

    $result = curl_exec($ch);
    curl_close($ch);

    dd($result);

As you can see I do have the "application/x-www-form-urlencoded" included, yet I still get a response:

{
  "error": "unsupported_grant_type",
  "error_description": "Invalid grant_type: "
}

I hope that someone will be able to help. Any tips, links, or code-snippets will do! Thank you!

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

POST https://accounts.google.com/o/oauth2/token
client_id={ClientId}&client_secret={ClientSecret}&refresh_token=[TOKEN]&grant_type=refresh_token

The call is a http POST call and the data is a single string with options separated by an & sign.

You are sending the post data as an array.

over 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