Oauth app : unsupported_grant_type

I created an OAuth app.
PHP:
I requested user authrorization and got the code.
With that code ( $code ), I’m trying to request access token.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://zoom.us/oauth/token");
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
	"Host: zoom.us",
    "Authorization: Basic ".$authorization,
    "Content-Type: application/x-www-form-urlencoded"
));
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
	'code' => $code,
	'grant_type' => 'authorization_code',
	'redirect_uri' => $redirect_uri,
));

$data = curl_exec($ch);

where $code is the code I got, $authorization is a base64_encode Client_ID:Client_Secret and $redirect_uri the needed url (whitelisted)

Unfortunatly I got an error:

{"reason":"unsupported grant type","error":"unsupported_grant_type"}

What’s wrong with the grant_type ?

When you are sending your request to authorize, are you using a code challenge? If so, make sure that you are using a code_verifier here to complete the PKCE flow.

We have more information on this here.

Let me know if that helps.

I don’t use PKCE flow its optionnal (on the documentation).

I request a user authorization with something like:

https://zoom.us/oauth/authorize?response_type=code&client_id=7lstjK9NTyett_oeXtFiEQ&redirect_uri=https://example.com

I do confirm that redirect_uri gives me a code like:

https://example.com/?code=obBEe8ewaL_KdyNjniT4KPd8ffDWt9fGB

ThenI use this code value in the script above and the answer is :

Oauth app : unsupported_grant_type

According to the documentation I don’t understand what’s wrong.

Forget it @MaxM :wink: Thanks for your help. I found an other solution. I swiched from OAuth app to Server-to-Server OAuth. And it works !

1 Like

Glad to hear you have a path forward!

1 Like