show10665
(MinXiu)
October 30, 2023, 6:12am
1
Format Your New Topic as Follows:
API Endpoint(s) and/or Zoom API Event(s)
Link the API endpoint(s) and/orZoom API Event(s) you’re working with to help give context.
Description
We tried to convert JWT to OAuth, but encountered difficulties. I did not get the Token, but I called the Zoom Api to create a Meeting in response to this message. Instead, I used “account_credentials” and “client_credentials”. We hope to create a meeting or initiate a meeting in the background.
ApiURL:https://api.zoom.us/v2
requestURL:POST /users/{email}/meetings
Error?
{
“code”: 124,
“message”: “This API does not support client credentials for authorization.”
}
How To Reproduce
The code is rather simple.
var Str_token = @“XXXXXXX”;
var client = new RestClient(@“https://api.zoom.us/v2 ”);
email = @“XXX@xxx.xxx.xx”;
var request = new RestRequest($“/users/{email}/meetings”, Method.POST);
request.RequestFormat = DataFormat.Json;
request.AddJsonBody(jsonData);
request.AddHeader(“content-type”, “application/json”);
request.AddHeader(“authorization”, $“Bearer {Str_token}”);
IRestResponse response = client.Execute(request);
var content = JsonConvert.DeserializeObject(response.Content);
chunsiong.zoom
(Chun Siong (tag me for response))
October 30, 2023, 7:14am
2
@show10665 , how are you generating your Str_token ?
show10665
(MinXiu)
October 30, 2023, 7:26am
3
I used the following code to get Token.
string tokenUrl = @"https://zoom.us/oauth/token";
string clientId = "xxxx";
string clientSecret = "xxxx";
string redirectUri = "xxxx";
string AuthorizationBasic = Convert.ToBase64String(Encoding.UTF8.GetBytes(clientId + ":" + clientSecret));
RestClient client = new RestClient(new Uri(tokenUrl));
RestRequest request = new RestRequest();
request.Method = Method.POST;
request.AddHeader("Authorization", $"Basic {AuthorizationBasic}");
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddParameter("grant_type", "client_credentials");
request.AddParameter("redirect_uri", redirectUri);
request.AddParameter("client_id", clientId);
request.AddParameter("client_seret", clientSecret);
IRestResponse response = client.Execute(request);
chunsiong.zoom
(Chun Siong (tag me for response))
October 30, 2023, 9:06am
4
MinXiu:
client_credentials
@show10665 can i confirm if you are using Server to Server Oauth or Oauth?
show10665
(MinXiu)
October 31, 2023, 1:25am
6
Server to Server Oauth and Oauth I’ve tried both and the results are still the same.
chunsiong.zoom
(Chun Siong (tag me for response))
October 31, 2023, 2:11am
7
@show10665 ,
If you are using Server to Server Oauth, here’s what I did in nodejs to get the bearer token
// Function to fetch a bearer token
async function fetchBearerToken() {
try {
// Create a Basic Authorization header with client credentials
const credentials = Buffer.from(`${process.env.ZOOM_S2S_CLIENT_ID}:${process.env.ZOOM_S2S_CLIENT_SECRET}`).toString('base64');
const apiUrl = `https://zoom.us/oauth/token?grant_type=account_credentials&account_id=${process.env.ZOOM_S2S_ACCOUNTID}`;
// Define the token request parameters
const tokenRequestData = {
method: 'POST',
url: apiUrl,
headers: {
'Authorization': `Basic ${credentials}`,
'Content-Type': 'application/x-www-form-urlencoded',
},
};
// Send the token request
const response = await axios(tokenRequestData);
// Extract the access token from the response
const accessToken = response.data.access_token;
// Return
return accessToken;
} catch (error) {
return error.message;
}
}
system
(system)
Closed
November 1, 2023, 6:03am
8
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.