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!
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.