Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) Zoom API - Create JWT to Authenticate API RequestsSee more Zoom ExamplesCreates a JWT for the Zoom API. For more information, see https://marketplace.zoom.us/docs/api-reference/using-zoom-apis#using-jwt
Use ChilkatAx-win32.pkg Procedure Test String sApiKey String sApiSecret Handle hoJwt Handle hoJose Boolean iSuccess Handle hoClaims Integer iCurDateTime Integer iOneMonth String sStrJwt Handle hoHttp Variant vSbResponseBody Handle hoSbResponseBody Handle hoJResp Integer iRespStatusCode String sId String sFirst_name String sLast_name String sEmail Integer iV_type Integer iPmi String sTimezone Integer iVerified String sCreated_at String sLast_login_time String sLanguage String sPhone_number String sStatus String sRole_id Integer iPage_count Integer iPage_number Integer iPage_size Integer iTotal_records Integer i Integer iCount_i String sTemp1 String sTemp2 // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // Use your API key and secret here... Move "o9rw6Gq0RnqlkfaSqtCMOA" To sApiKey Move "UslmE23Kjh7at9z3If1xAHEyLmPDNxvxQrjR" To sApiSecret // Create a JWT to authenticate Zoom API requests. Get Create (RefClass(cComChilkatJwt)) To hoJwt If (Not(IsComObjectCreated(hoJwt))) Begin Send CreateComObject of hoJwt End Get Create (RefClass(cComChilkatJsonObject)) To hoJose If (Not(IsComObjectCreated(hoJose))) Begin Send CreateComObject of hoJose End Get ComUpdateString Of hoJose "alg" "HS256" To iSuccess Get ComUpdateString Of hoJose "typ" "JWT" To iSuccess // Build claims to look like this: // {"aud":null,"iss":"o9rw6Gq0RnqlkfaSqtCMOA","exp":1627651762,"iat":1627646363} Get Create (RefClass(cComChilkatJsonObject)) To hoClaims If (Not(IsComObjectCreated(hoClaims))) Begin Send CreateComObject of hoClaims End Get ComUpdateString Of hoClaims "iss" sApiKey To iSuccess Get ComUpdateNull Of hoClaims "aud" To iSuccess // Set the timestamp of when the JWT was created to now. Get ComGenNumericDate Of hoJwt 0 To iCurDateTime Get ComAddIntAt Of hoClaims -1 "iat" iCurDateTime To iSuccess // Set the timestamp defining an expiration time (end time) for the token // to be now + 1 month(3600 * 24 * 30 seconds) Move (3600 * 24 * 30) To iOneMonth Get ComAddIntAt Of hoClaims -1 "exp" (iCurDateTime + iOneMonth) To iSuccess // Produce the smallest possible JWT: Set ComAutoCompact Of hoJwt To True Get ComEmit Of hoJose To sTemp1 Get ComEmit Of hoClaims To sTemp2 Get ComCreateJwt Of hoJwt sTemp1 sTemp2 sApiSecret To sStrJwt Showln sStrJwt // Let's test the JWT to by sending the following request: // curl --request GET \ // --url 'https://api.zoom.us/v2/users?status=active&page_size=30&page_number=1' \ // --header 'authorization: Bearer { your_token }' \ // --header 'content-type: application/json Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End // Implements the following CURL command: // curl --request GET \ // --url 'https://api.zoom.us/v2/users?status=active&page_size=30&page_number=1' \ // --header 'authorization: Bearer { your_token }' \ // --header 'content-type: application/json // Use the following online tool to generate HTTP code from a CURL command // Convert a cURL Command to HTTP Source Code Send ComSetRequestHeader To hoHttp "content-type" "application/json" // Adds the "Authorization: Bearer { your_token }" header. Set ComAuthToken Of hoHttp To sStrJwt Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody If (Not(IsComObjectCreated(hoSbResponseBody))) Begin Send CreateComObject of hoSbResponseBody End Get pvComObject of hoSbResponseBody to vSbResponseBody Get ComQuickGetSb Of hoHttp "https://api.zoom.us/v2/users?status=active&page_size=30&page_number=1" vSbResponseBody To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End Get Create (RefClass(cComChilkatJsonObject)) To hoJResp If (Not(IsComObjectCreated(hoJResp))) Begin Send CreateComObject of hoJResp End Get pvComObject of hoSbResponseBody to vSbResponseBody Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess Set ComEmitCompact Of hoJResp To False Showln "Response Body:" Get ComEmit Of hoJResp To sTemp1 Showln sTemp1 Get ComLastStatus Of hoHttp To iRespStatusCode Showln "Response Status Code = " iRespStatusCode If (iRespStatusCode >= 400) Begin Showln "Response Header:" Get ComLastHeader Of hoHttp To sTemp1 Showln sTemp1 Showln "Failed." Procedure_Return End // Sample output: // { // "page_count": 1, // "page_number": 1, // "page_size": 30, // "total_records": 1, // "users": [ // { // "id": "s8uAiMJiRmS_-eu1yOhKlg", // "first_name": "Joe", // "last_name": "Example", // "email": "joe@example.com", // "type": 1, // "pmi": 5224934114, // "timezone": "America/Chicago", // "verified": 1, // "created_at": "2021-07-30T11:56:37Z", // "last_login_time": "2021-07-30T11:56:37Z", // "language": "en-US", // "phone_number": "", // "status": "active", // "role_id": "0" // } // ] // } // Sample code for parsing the JSON response... // Use the following online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON Get ComIntOf Of hoJResp "page_count" To iPage_count Get ComIntOf Of hoJResp "page_number" To iPage_number Get ComIntOf Of hoJResp "page_size" To iPage_size Get ComIntOf Of hoJResp "total_records" To iTotal_records Move 0 To i Get ComSizeOfArray Of hoJResp "users" To iCount_i While (i < iCount_i) Set ComI Of hoJResp To i Get ComStringOf Of hoJResp "users[i].id" To sId Get ComStringOf Of hoJResp "users[i].first_name" To sFirst_name Get ComStringOf Of hoJResp "users[i].last_name" To sLast_name Get ComStringOf Of hoJResp "users[i].email" To sEmail Get ComIntOf Of hoJResp "users[i].type" To iV_type Get ComIntOf Of hoJResp "users[i].pmi" To iPmi Get ComStringOf Of hoJResp "users[i].timezone" To sTimezone Get ComIntOf Of hoJResp "users[i].verified" To iVerified Get ComStringOf Of hoJResp "users[i].created_at" To sCreated_at Get ComStringOf Of hoJResp "users[i].last_login_time" To sLast_login_time Get ComStringOf Of hoJResp "users[i].language" To sLanguage Get ComStringOf Of hoJResp "users[i].phone_number" To sPhone_number Get ComStringOf Of hoJResp "users[i].status" To sStatus Get ComStringOf Of hoJResp "users[i].role_id" To sRole_id Move (i + 1) To i Loop End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.