Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

PowerBuilder Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun
Mastercard

MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(PowerBuilder) Zoom API - Create JWT to Authenticate API Requests

See more Zoom Examples

Creates a JWT for the Zoom API.

For more information, see https://marketplace.zoom.us/docs/api-reference/using-zoom-apis#using-jwt

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

integer li_rc
string ls_ApiKey
string ls_ApiSecret
oleobject loo_Jwt
oleobject loo_Jose
integer li_Success
oleobject loo_Claims
integer li_CurDateTime
integer li_OneMonth
string ls_StrJwt
oleobject loo_Http
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Id
string ls_First_name
string ls_Last_name
string ls_Email
integer li_V_type
integer li_Pmi
string ls_Timezone
integer li_Verified
string ls_Created_at
string ls_Last_login_time
string ls_Language
string ls_Phone_number
string ls_Status
string ls_Role_id
integer li_Page_count
integer li_Page_number
integer li_Page_size
integer li_Total_records
integer i
integer li_Count_i

// 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...
ls_ApiKey = "o9rw6Gq0RnqlkfaSqtCMOA"
ls_ApiSecret = "UslmE23Kjh7at9z3If1xAHEyLmPDNxvxQrjR"

// Create a JWT to authenticate Zoom API requests.
loo_Jwt = create oleobject
li_rc = loo_Jwt.ConnectToNewObject("Chilkat_9_5_0.Jwt")
if li_rc < 0 then
    destroy loo_Jwt
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Jose = create oleobject
li_rc = loo_Jose.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

li_Success = loo_Jose.UpdateString("alg","HS256")
li_Success = loo_Jose.UpdateString("typ","JWT")

// Build claims to look like this:
// {"aud":null,"iss":"o9rw6Gq0RnqlkfaSqtCMOA","exp":1627651762,"iat":1627646363}
loo_Claims = create oleobject
li_rc = loo_Claims.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

li_Success = loo_Claims.UpdateString("iss",ls_ApiKey)
li_Success = loo_Claims.UpdateNull("aud")

// Set the timestamp of when the JWT was created to now.
li_CurDateTime = loo_Jwt.GenNumericDate(0)
li_Success = loo_Claims.AddIntAt(-1,"iat",li_CurDateTime)

// Set the timestamp defining an expiration time (end time) for the token
// to be now + 1 month(3600 * 24 * 30 seconds)
li_OneMonth = 3600 * 24 * 30
li_Success = loo_Claims.AddIntAt(-1,"exp",li_CurDateTime + li_OneMonth)

// Produce the smallest possible JWT:
loo_Jwt.AutoCompact = 1

ls_StrJwt = loo_Jwt.CreateJwt(loo_Jose.Emit(),loo_Claims.Emit(),ls_ApiSecret)

Write-Debug ls_StrJwt

// 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

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")

// 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

loo_Http.SetRequestHeader("content-type","application/json")
// Adds the "Authorization: Bearer { your_token }" header.
loo_Http.AuthToken = ls_StrJwt

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

li_Success = loo_Http.QuickGetSb("https://api.zoom.us/v2/users?status=active&page_size=30&page_number=1",loo_SbResponseBody)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Jwt
    destroy loo_Jose
    destroy loo_Claims
    destroy loo_Http
    destroy loo_SbResponseBody
    return
end if

loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Http.LastHeader
    Write-Debug "Failed."
    destroy loo_Jwt
    destroy loo_Jose
    destroy loo_Claims
    destroy loo_Http
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

// 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

li_Page_count = loo_JResp.IntOf("page_count")
li_Page_number = loo_JResp.IntOf("page_number")
li_Page_size = loo_JResp.IntOf("page_size")
li_Total_records = loo_JResp.IntOf("total_records")
i = 0
li_Count_i = loo_JResp.SizeOfArray("users")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Id = loo_JResp.StringOf("users[i].id")
    ls_First_name = loo_JResp.StringOf("users[i].first_name")
    ls_Last_name = loo_JResp.StringOf("users[i].last_name")
    ls_Email = loo_JResp.StringOf("users[i].email")
    li_V_type = loo_JResp.IntOf("users[i].type")
    li_Pmi = loo_JResp.IntOf("users[i].pmi")
    ls_Timezone = loo_JResp.StringOf("users[i].timezone")
    li_Verified = loo_JResp.IntOf("users[i].verified")
    ls_Created_at = loo_JResp.StringOf("users[i].created_at")
    ls_Last_login_time = loo_JResp.StringOf("users[i].last_login_time")
    ls_Language = loo_JResp.StringOf("users[i].language")
    ls_Phone_number = loo_JResp.StringOf("users[i].phone_number")
    ls_Status = loo_JResp.StringOf("users[i].status")
    ls_Role_id = loo_JResp.StringOf("users[i].role_id")
    i = i + 1
loop


destroy loo_Jwt
destroy loo_Jose
destroy loo_Claims
destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.