Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

790
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!