Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Visual FoxPro Web API Examples

Primary Categories

AWS Translate
Activix CRM
Adyen
Amazon MWS
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Bluzone
CardConnect
ClickBank
Clickatell
Cloudfare
DocuSign
ETrade
Etsy
Facebook
GeoOp
GetHarvest
Jira
MYOB

Magento
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Okta OAuth/OIDC
OneLogin OIDC
PayPal
Peoplevox
Populi
QuickBooks
SOAP finkok.com
Shippo
Shopify
Stripe
SugarCRM
Trello
Twitter
VoiceBase
Vonage
Walmart
Walmart v3
Xero
eBay
effectconnect

 

 

 

(Visual FoxPro) Okta: Use the Resource Owner Password Flow

Demonstrates how to get an access token using the Resource Owner Password Flow.

For more information, see https://developer.okta.com/docs/guides/implement-password/use-flow/

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

LOCAL loHttp
LOCAL lnSuccess
LOCAL loReq
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcAccess_token
LOCAL lcToken_type
LOCAL lnExpires_in
LOCAL lcScope
LOCAL lcId_token

* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

loHttp = CreateObject('Chilkat_9_5_0.Http')

* Implements the following CURL command:

* curl --request POST \
*   --url https://{yourOktaDomain}/oauth2/default/v1/token \
*   --header 'accept: application/json' \
*   --user "client_id:client_secret" \
*   --header 'content-type: application/x-www-form-urlencoded' \
*   --data 'grant_type=password&username=myUserEmail&password=myPassword&scope=openid'

loHttp.Login = "client_id"
loHttp.Password = "client_secret"

loReq = CreateObject('Chilkat_9_5_0.HttpRequest')
loReq.HttpVerb = "POST"
loReq.Path = "/oauth2/default/v1/token"
loReq.ContentType = "application/x-www-form-urlencoded"
loReq.AddParam("grant_type","password")
loReq.AddParam("username","myUserEmail")
loReq.AddParam("password","myPassword")
loReq.AddParam("scope","openid")

loReq.AddHeader("accept","application/json")

loResp = loHttp.PostUrlEncoded("https://{yourOktaDomain}/oauth2/default/v1/token",loReq)
IF (loHttp.LastMethodSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loReq
    CANCEL
ENDIF

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

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

lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
    ? "Response Header:"
    ? loResp.Header
    ? "Failed."
    RELEASE loResp
    RELEASE loHttp
    RELEASE loReq
    RELEASE loSbResponseBody
    RELEASE loJResp
    CANCEL
ENDIF

RELEASE loResp

* Sample JSON response:
* (Sample code for parsing the JSON response is shown below)

* {
*   "access_token": "eyJraWQiOi ... jmiHD7wY9_gQ",
*   "token_type": "Bearer",
*   "expires_in": 3600,
*   "scope": "openid",
*   "id_token": "eyJraWQiOiJ ... W7KkWiPJnUSMoGw"
* }

* Sample code for parsing the JSON response...
* Use the following online tool to generate parsing code from sample JSON:
* Generate Parsing Code from JSON

lcAccess_token = loJResp.StringOf("access_token")
lcToken_type = loJResp.StringOf("token_type")
lnExpires_in = loJResp.IntOf("expires_in")
lcScope = loJResp.StringOf("scope")
lcId_token = loJResp.StringOf("id_token")

RELEASE loHttp
RELEASE loReq
RELEASE loSbResponseBody
RELEASE loJResp


 

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