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
(Tcl) 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
load ./chilkat.dll # 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' set cert [new_CkCert] set success [CkCert_LoadFromFile $cert "qa_data/certs/TPPCertificate.cer"] if {$success != 1} then { puts [CkCert_lastErrorText $cert] delete_CkCert $cert exit } set bdKey [new_CkBinData] set success [CkBinData_LoadFile $bdKey "qa_data/certs/TPPprivateKey.key"] set privKey [new_CkPrivateKey] set success [CkPrivateKey_LoadAnyFormat $privKey $bdKey "passwordIfNeeded"] if {$success != 1} then { puts [CkPrivateKey_lastErrorText $privKey] delete_CkCert $cert delete_CkBinData $bdKey delete_CkPrivateKey $privKey exit } set success [CkCert_SetPrivateKey $cert $privKey] if {$success != 1} then { puts [CkCert_lastErrorText $cert] delete_CkCert $cert delete_CkBinData $bdKey delete_CkPrivateKey $privKey exit } set http [new_CkHttp] set success [CkHttp_SetSslClientCert $http $cert] if {$success != 1} then { puts [CkHttp_lastErrorText $http] delete_CkCert $cert delete_CkBinData $bdKey delete_CkPrivateKey $privKey delete_CkHttp $http exit } set req [new_CkHttpRequest] CkHttpRequest_AddParam $req "grant_type" "client_credentials" CkHttpRequest_AddParam $req "client_id" "TPP_test" CkHttpRequest_AddParam $req "scope" "psd2:payment:sepa:write psd2:payment:sepa:read" # resp is a CkHttpResponse set resp [CkHttp_PostUrlEncoded $http "https://auth-sandbox.connect.abnamro.com:8443/as/token.oauth2" $req] if {[CkHttp_get_LastMethodSuccess $http] == 0} then { puts [CkHttp_lastErrorText $http] delete_CkCert $cert delete_CkBinData $bdKey delete_CkPrivateKey $privKey delete_CkHttp $http delete_CkHttpRequest $req exit } if {[CkHttpResponse_get_StatusCode $resp] != 200} then { puts [CkHttpResponse_bodyStr $resp] delete_CkHttpResponse $resp delete_CkCert $cert delete_CkBinData $bdKey delete_CkPrivateKey $privKey delete_CkHttp $http delete_CkHttpRequest $req exit } # Get the JSON result: # {"access_token":"TIhycwl8rfrZPkXGw15mwldASAAK","token_type":"Bearer","expires_in":7200} set json [new_CkJsonObject] CkJsonObject_Load $json [CkHttpResponse_bodyStr $resp] puts "access_token: [CkJsonObject_stringOf $json access_token]" puts "token_type: [CkJsonObject_stringOf $json token_type]" puts "expires_in: [CkJsonObject_stringOf $json expires_in]" delete_CkHttpResponse $resp delete_CkCert $cert delete_CkBinData $bdKey delete_CkPrivateKey $privKey delete_CkHttp $http delete_CkHttpRequest $req delete_CkJsonObject $json |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.