{"reason":"Invalid Grant","error":"invalid_grant"}

Hello everybody,

I’m trying to generate a token from https://zoom.us/oauth/token and I’m receiving an error:

{“reason”:“Invalid Grant”,“error”:“invalid_grant”}

I have checked that the authorization header is being well generated through this method:

private string GetAuthorizationHeader()
{
var plainText = $“{_zoomMeetingConfiguration.ClientId}:{_zoomMeetingConfiguration.ClientSecret}”;
var plainTextBytes = ASCIIEncoding.ASCII.GetBytes(plainText);
var encodedString = Convert.ToBase64String(plainTextBytes);
return encodedString;
}

I have double-checked that the ClientId and ClientSecret are correct according to our application. I’m calling the API like this:

var dict = new Dictionary<string, string>
{
{ “redirect_uri”, _zoomMeetingConfiguration.RedirectUri },
{ “grant_type”, “authorization_code” },
{ “code”, authorizationCode }
};

Uri baseUri = new Uri(“https://zoom.us”);
var requestBody = new FormUrlEncodedContent(dict);
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(“Basic”, GetAuthorizationHeader());
_httpClient.DefaultRequestHeaders.Host = baseUri.Host;
var response = await _httpClient.PostAsync(tokenPath, requestBody);

Can anybody please help me get what I’m doing wrong?

Thanks in advance.

Hey @Babele ,

Please review this troubleshooting guide: Troubleshooting Server-to-Server Oauth access tokens

In addition to our token generation samples:

Hey @gianni.zoom,

Thanks for your reply. It was missing some details. My application is the type OAuth, not the Server-to-Server Oauth.

Note that the error and the request are different than my scenario.

Thanks again for your attention.

Hi @Babele ,

Are you using a legacy OAuth application or Unified Build Flow?