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

Visual FoxPro 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
Google Vision
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

 

 

 

(Visual FoxPro) 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

LOCAL lcApiKey
LOCAL lcApiSecret
LOCAL loJwt
LOCAL loJose
LOCAL lnSuccess
LOCAL loClaims
LOCAL lnCurDateTime
LOCAL lnOneMonth
LOCAL lcStrJwt
LOCAL loHttp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcId
LOCAL lcFirst_name
LOCAL lcLast_name
LOCAL lcEmail
LOCAL lnV_type
LOCAL lnPmi
LOCAL lcTimezone
LOCAL lnVerified
LOCAL lcCreated_at
LOCAL lcLast_login_time
LOCAL lcLanguage
LOCAL lcPhone_number
LOCAL lcStatus
LOCAL lcRole_id
LOCAL lnPage_count
LOCAL lnPage_number
LOCAL lnPage_size
LOCAL lnTotal_records
LOCAL i
LOCAL lnCount_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...
lcApiKey = "o9rw6Gq0RnqlkfaSqtCMOA"
lcApiSecret = "UslmE23Kjh7at9z3If1xAHEyLmPDNxvxQrjR"

* Create a JWT to authenticate Zoom API requests.
loJwt = CreateObject('Chilkat_9_5_0.Jwt')

loJose = CreateObject('Chilkat_9_5_0.JsonObject')
lnSuccess = loJose.UpdateString("alg","HS256")
lnSuccess = loJose.UpdateString("typ","JWT")

* Build claims to look like this:
* {"aud":null,"iss":"o9rw6Gq0RnqlkfaSqtCMOA","exp":1627651762,"iat":1627646363}
loClaims = CreateObject('Chilkat_9_5_0.JsonObject')
lnSuccess = loClaims.UpdateString("iss",lcApiKey)
lnSuccess = loClaims.UpdateNull("aud")

* Set the timestamp of when the JWT was created to now.
lnCurDateTime = loJwt.GenNumericDate(0)
lnSuccess = loClaims.AddIntAt(-1,"iat",lnCurDateTime)

* Set the timestamp defining an expiration time (end time) for the token
* to be now + 1 month(3600 * 24 * 30 seconds)
lnOneMonth = 3600 * 24 * 30
lnSuccess = loClaims.AddIntAt(-1,"exp",lnCurDateTime + lnOneMonth)

* Produce the smallest possible JWT:
loJwt.AutoCompact = 1

lcStrJwt = loJwt.CreateJwt(loJose.Emit(),loClaims.Emit(),lcApiSecret)

? lcStrJwt

* 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

loHttp = CreateObject('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

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

loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loHttp.QuickGetSb("https://api.zoom.us/v2/users?status=active&page_size=30&page_number=1",loSbResponseBody)
IF (lnSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loJwt
    RELEASE loJose
    RELEASE loClaims
    RELEASE loHttp
    RELEASE loSbResponseBody
    CANCEL
ENDIF

loJResp = CreateObject('Chilkat_9_5_0.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loHttp.LastStatus
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
    ? "Response Header:"
    ? loHttp.LastHeader
    ? "Failed."
    RELEASE loJwt
    RELEASE loJose
    RELEASE loClaims
    RELEASE loHttp
    RELEASE loSbResponseBody
    RELEASE loJResp
    CANCEL
ENDIF

* 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

lnPage_count = loJResp.IntOf("page_count")
lnPage_number = loJResp.IntOf("page_number")
lnPage_size = loJResp.IntOf("page_size")
lnTotal_records = loJResp.IntOf("total_records")
i = 0
lnCount_i = loJResp.SizeOfArray("users")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcId = loJResp.StringOf("users[i].id")
    lcFirst_name = loJResp.StringOf("users[i].first_name")
    lcLast_name = loJResp.StringOf("users[i].last_name")
    lcEmail = loJResp.StringOf("users[i].email")
    lnV_type = loJResp.IntOf("users[i].type")
    lnPmi = loJResp.IntOf("users[i].pmi")
    lcTimezone = loJResp.StringOf("users[i].timezone")
    lnVerified = loJResp.IntOf("users[i].verified")
    lcCreated_at = loJResp.StringOf("users[i].created_at")
    lcLast_login_time = loJResp.StringOf("users[i].last_login_time")
    lcLanguage = loJResp.StringOf("users[i].language")
    lcPhone_number = loJResp.StringOf("users[i].phone_number")
    lcStatus = loJResp.StringOf("users[i].status")
    lcRole_id = loJResp.StringOf("users[i].role_id")
    i = i + 1
ENDDO

RELEASE loJwt
RELEASE loJose
RELEASE loClaims
RELEASE loHttp
RELEASE loSbResponseBody
RELEASE loJResp


 

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