The access_token is always 632 characters long, and when I test it in Postman it works fine
Postman Code:
using System;
using RestSharp;
namespace HelloWorldApplication {
class HelloWorld {
static void Main(string[] args) {
var client = new RestClient("https://zoom.us/oauth/token?account_id=VfdA06Q9TQe31jH7oRutuQ&grant_type=account_credentials");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Basic ####");
request.AddHeader("Cookie", "####");
var body = @"";
request.AddParameter("text/plain", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
}
}
}
I have a limitation that prevents me from using RestSharp. As such, I am using System.Net.Http in my application, but the access_token is always 533 characters long. I get unauthorized response whenever I use that token which is what alerted me that something may be wrong with it.
System.Net.Http Code
using System;
using System.Collections.Generic;
using System.Net.Http;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace ConsoleApp_Test_ZoomCreateMeeting
{
class Program
{
static void Main(string[] args)
{
//Get current token age
// Get the get credentials
// Build the request body
var authRequestBody = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("grant_type", "client_credentials"),
new KeyValuePair<string, string>("client_id", "####"),
new KeyValuePair<string, string>("client_secret", "####")
});
// Set up the HTTP client
var authClient = new HttpClient();
authClient.BaseAddress = new Uri("https://zoom.us/");
// Send the request and get the response
HttpResponseMessage authResponse = authClient.PostAsync("oauth/token", authRequestBody).Result;
string content = authResponse.Content.ReadAsStringAsync().Result;
long contentLength = authResponse.Content.Headers.ContentLength ?? 0;
string responseContent = authResponse.Content.ReadAsStringAsync().Result;
// Parse the JSON response
JObject jsonResponse = JsonConvert.DeserializeObject<JObject>(responseContent);
// Create an instance of JsonSerializerSettings and set the ReferenceLoopHandling property to Ignore
JsonSerializerSettings serializerSettings = new JsonSerializerSettings();
serializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
// Serialize the jsonResponse object using the JsonSerializerSettings object
string serializedJsonResponse = JsonConvert.SerializeObject(jsonResponse, serializerSettings);
// Extract the access_token property (value<t>)
string currentToken = jsonResponse["access_token"].Value<string>();
Console.WriteLine("Current Token: " + currentToken);
}
}
}
Any ideas on a solution here?
I tried to request an OAuth token from the Zoom API, and though I received one, the access_token attribute is being cut short
Although this thread is older, with Zoom JWT App Type deprecating soon, it seems that this thread could gain traction in the near future. The following uses Zoom Server-to-Server Auth, but can be adjusted for Zoom OAuth.
To begin, Account ID, Client ID, and Client Secret are needed. This can be found in [Created Apps → Your App → App Credentials].
A valid Zoom Access Token takes the form of:
It gets a little confusing reading Zoom API [https://developers.zoom.us/docs/internal-apps/s2s-oauth/], but mapping a ZoomAccessToken object via a HTTP request boils down to this:
The following code is currently implemented in my Zoom Server-to-Server Auth Application to retrieve a valid Zoom Access Token, for reference:
Before using the Zoom Access Token (ex. getting Zoom user information), ensure your Zoom Scopes are correct [Created Apps → Your App → Scopes]
Zoom Access Token Usage: