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
(Visual FoxPro) Retrieve the Okta JSON Web Keys (JWK)Demonstrates how to get the Okta web keys (JWK) that will be needed to locally validate an access token. This example is for the case where Okta is the identity platform for your App or API. (See https://developer.okta.com/docs/reference/api/oidc/#composing-your-base-url) Note: This example uses the URL https://dev-765951.okta.com/oauth2/${authServerId}/v1/authorize If you have a developer account, you can use the default authorization server that was created along with your account, in which case the full URL looks like this: https://dev-765951.okta.com/oauth2/default/v1/authorize Also: You'll need to change "dev-765951" to use your own Okta domain. For more information, see https://developer.okta.com/docs/reference/api/oidc/#keys
LOCAL loHttp LOCAL lnSuccess LOCAL loSbResponseBody LOCAL loJResp LOCAL lnRespStatusCode LOCAL lcKty LOCAL lcAlg LOCAL lcKid LOCAL lcUse LOCAL e LOCAL n LOCAL i LOCAL lnCount_i * This example assumes the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http') loHttp = CreateObject('Chilkat.Http') * Implements the following CURL command: * curl -X GET \ * https://dev-765951.okta.com/oauth2/${authServerId}/v1/keys?client_id=$my_client_id * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbResponseBody = CreateObject('Chilkat.StringBuilder') lnSuccess = loHttp.QuickGetSb("https://dev-765951.okta.com/oauth2/${authServerId}/v1/keys?client_id=$my_client_id",loSbResponseBody) IF (lnSuccess = 0) THEN ? loHttp.LastErrorText RELEASE loHttp RELEASE loSbResponseBody CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJResp = CreateObject('Chilkat.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 loHttp RELEASE loSbResponseBody RELEASE loJResp CANCEL ENDIF * Sample JSON response: * (Sample code for parsing the JSON response is shown below) * { * "keys": [ * { * "kty": "RSA", * "alg": "RS256", * "kid": "anSaRDPfWGOSCVNZEIZB9quCbNsdsvl5uWGBzxbudWQ", * "use": "sig", * "e": "AQAB", * "n": "jT8uAgd5wF7d3aiCjdxbVXk7EDio2ScqAjWCL2LXbY3bpj6RV4dswZTqBg0-vuIh1SBqjoufDV3fHAJcewv2dfEdfUKawBxTIcLgeSu_NoUsZ6zmHqYKC9U0awgP3s5_Yqcr7YMxurrPRNRdKNsFFF2lhCDJ-4gCO4CWiCUdptlmMfI7_pBxx9bgh1F-ulVKt_RUo-4A7tXwwJhBhWaECKoye04BACccSNkth8flGSvjXNIVKcAMHYQ3oDfB6U5zXcFuDVEBJI__hzA9920QRXrloIv_G0QmYgbaf4iRpd-3B6-PQ4-VK-FGm3t9eTwoFv6CARpyXrjaOeuLB1HaVw" * } * ] * } * Sample code for parsing the JSON response... * Use the following online tool to generate parsing code from sample JSON: * Generate Parsing Code from JSON i = 0 lnCount_i = loJResp.SizeOfArray("keys") DO WHILE i < lnCount_i loJResp.I = i lcKty = loJResp.StringOf("keys[i].kty") lcAlg = loJResp.StringOf("keys[i].alg") lcKid = loJResp.StringOf("keys[i].kid") lcUse = loJResp.StringOf("keys[i].use") e = loJResp.StringOf("keys[i].e") n = loJResp.StringOf("keys[i].n") i = i + 1 ENDDO RELEASE loHttp RELEASE loSbResponseBody RELEASE loJResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.