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.