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
(PowerBuilder) Duo Auth API - PreauthSee more Duo Auth MFA ExamplesThe /preauth endpoint determines whether a user is authorized to log in, and (if so) returns the user's available authentication factors. Note: This example requires Chilkat v9.5.0.89 or greater. For more information, see https://duo.com/docs/authapi#/preauth
integer li_rc string ls_IntegrationKey string ls_SecretKey oleobject loo_Http string ls_Url oleobject loo_Req oleobject loo_Resp oleobject loo_Json integer li_Success string ls_Device string ls_Display_name string ls_Name string ls_Number string ls_V_type integer j integer li_Count_j string ls_StrVal string ls_ResponseResult string ls_ResponseStatus_msg string ls_Stat integer i integer li_Count_i // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. ls_IntegrationKey = "DIMS3V5QDVG9J9ABRXC4" ls_SecretKey = "HWVQ46nubLBxhnRlKddTltWIi3hL0fIQF2qTvLab" loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") if li_rc < 0 then destroy loo_Http MessageBox("Error","Connecting to COM object failed") return end if loo_Http.Accept = "application/json" // Use your own hostname here: ls_Url = "https://api-a03782e1.duosecurity.com/auth/v2/preauth" // This example requires Chilkat v9.5.0.89 or greater because Chilkat will automatically // generate and send the HMAC signature for the requires based on the integration key and secret key. loo_Http.Login = ls_IntegrationKey loo_Http.Password = ls_SecretKey loo_Req = create oleobject // Use "Chilkat_9_5_0.HttpRequest" for versions of Chilkat < 10.0.0 li_rc = loo_Req.ConnectToNewObject("Chilkat.HttpRequest") loo_Req.AddParam("username","matt") loo_Resp = loo_Http.PostUrlEncoded(ls_Url,loo_Req) if loo_Http.LastMethodSuccess = 0 then Write-Debug loo_Http.LastErrorText destroy loo_Http destroy loo_Req return end if Write-Debug "status code = " + string(loo_Resp.StatusCode) loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") li_Success = loo_Json.Load(loo_Resp.BodyStr) loo_Json.EmitCompact = 0 Write-Debug loo_Json.Emit() destroy loo_Resp // Sample successful output: // status code = 200 // { // "response": { // "devices": [ // { // "capabilities": [ // "auto", // "push", // "sms", // "mobile_otp" // ], // "device": "DP6GYVTQ5NK82BMR851F", // "display_name": "iOS (XXX-XXX-1871)", // "name": "", // "number": "XXX-XXX-1871", // "type": "phone" // } // ], // "result": "auth", // "status_msg": "Account is active" // }, // "stat": "OK" // } // Sample code to parse the above JSON response.. // Use this online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON ls_ResponseResult = loo_Json.StringOf("response.result") ls_ResponseStatus_msg = loo_Json.StringOf("response.status_msg") ls_Stat = loo_Json.StringOf("stat") i = 0 li_Count_i = loo_Json.SizeOfArray("response.devices") do while i < li_Count_i loo_Json.I = i ls_Device = loo_Json.StringOf("response.devices[i].device") ls_Display_name = loo_Json.StringOf("response.devices[i].display_name") ls_Name = loo_Json.StringOf("response.devices[i].name") ls_Number = loo_Json.StringOf("response.devices[i].number") ls_V_type = loo_Json.StringOf("response.devices[i].type") j = 0 li_Count_j = loo_Json.SizeOfArray("response.devices[i].capabilities") do while j < li_Count_j loo_Json.J = j ls_StrVal = loo_Json.StringOf("response.devices[i].capabilities[j]") j = j + 1 loop i = i + 1 loop destroy loo_Http destroy loo_Req destroy loo_Json |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.