Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

792
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda