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) ABN AMRO OAuth2 Client Credentials AuthenticationDemonstrates how to obtain an access token for an ABN AMRO online API using OAuth2 with the Client Credentials flow. For more information, see https://developer.abnamro.com/api/payment-initiation-v1/payment-initiation-tutorial
integer li_rc oleobject loo_Cert integer li_Success oleobject loo_BdKey oleobject loo_PrivKey oleobject loo_Http oleobject loo_Req oleobject loo_Resp oleobject loo_Json // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // This example sends the following CURL request: // curl -X POST -k https://auth-sandbox.connect.abnamro.com:8443/as/token.oauth2 \ // -v \ // --cert TPPCertificate.crt \ // --key TPPprivateKey.key \ // -H 'Cache-Control: no-cache' \ // -H 'Content-Type: application/x-www-form-urlencoded' \ // -d 'grant_type=client_credentials&client_id=TPP_test&scope=psd2:payment:sepa:write psd2:payment:sepa:read' loo_Cert = create oleobject // Use "Chilkat_9_5_0.Cert" for versions of Chilkat < 10.0.0 li_rc = loo_Cert.ConnectToNewObject("Chilkat.Cert") if li_rc < 0 then destroy loo_Cert MessageBox("Error","Connecting to COM object failed") return end if li_Success = loo_Cert.LoadFromFile("qa_data/certs/TPPCertificate.cer") if li_Success <> 1 then Write-Debug loo_Cert.LastErrorText destroy loo_Cert return end if loo_BdKey = create oleobject // Use "Chilkat_9_5_0.BinData" for versions of Chilkat < 10.0.0 li_rc = loo_BdKey.ConnectToNewObject("Chilkat.BinData") li_Success = loo_BdKey.LoadFile("qa_data/certs/TPPprivateKey.key") loo_PrivKey = create oleobject // Use "Chilkat_9_5_0.PrivateKey" for versions of Chilkat < 10.0.0 li_rc = loo_PrivKey.ConnectToNewObject("Chilkat.PrivateKey") li_Success = loo_PrivKey.LoadAnyFormat(loo_BdKey,"passwordIfNeeded") if li_Success <> 1 then Write-Debug loo_PrivKey.LastErrorText destroy loo_Cert destroy loo_BdKey destroy loo_PrivKey return end if li_Success = loo_Cert.SetPrivateKey(loo_PrivKey) if li_Success <> 1 then Write-Debug loo_Cert.LastErrorText destroy loo_Cert destroy loo_BdKey destroy loo_PrivKey return end if loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") li_Success = loo_Http.SetSslClientCert(loo_Cert) if li_Success <> 1 then Write-Debug loo_Http.LastErrorText destroy loo_Cert destroy loo_BdKey destroy loo_PrivKey destroy loo_Http return end if 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("grant_type","client_credentials") loo_Req.AddParam("client_id","TPP_test") loo_Req.AddParam("scope","psd2:payment:sepa:write psd2:payment:sepa:read") loo_Resp = loo_Http.PostUrlEncoded("https://auth-sandbox.connect.abnamro.com:8443/as/token.oauth2",loo_Req) if loo_Http.LastMethodSuccess = 0 then Write-Debug loo_Http.LastErrorText destroy loo_Cert destroy loo_BdKey destroy loo_PrivKey destroy loo_Http destroy loo_Req return end if if loo_Resp.StatusCode <> 200 then Write-Debug loo_Resp.BodyStr destroy loo_Resp destroy loo_Cert destroy loo_BdKey destroy loo_PrivKey destroy loo_Http destroy loo_Req return end if // Get the JSON result: // {"access_token":"TIhycwl8rfrZPkXGw15mwldASAAK","token_type":"Bearer","expires_in":7200} loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") loo_Json.Load(loo_Resp.BodyStr) Write-Debug "access_token: " + loo_Json.StringOf("access_token") Write-Debug "token_type: " + loo_Json.StringOf("token_type") Write-Debug "expires_in: " + loo_Json.StringOf("expires_in") destroy loo_Resp destroy loo_Cert destroy loo_BdKey destroy loo_PrivKey destroy loo_Http destroy loo_Req destroy loo_Json |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.