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
(AutoIt) Banco Inter OAuth2 Client CredentialsGenerate an OAuth2 access token needed to consume the Inter APIs. For more information, see https://developers.bancointer.com.br/reference/token-3
; This example assumes the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. $oHttp = ObjCreate("Chilkat.Http") Local $bSuccess ; First load the certificate and private key, and set as the HTTP object's client certificate. $oCert = ObjCreate("Chilkat.Cert") $bSuccess = $oCert.LoadFromFile("<nome arquivo certificado>.crt") If ($bSuccess = False) Then ConsoleWrite($oCert.LastErrorText & @CRLF) Exit EndIf $oBdPrivKey = ObjCreate("Chilkat.BinData") $bSuccess = $oBdPrivKey.LoadFile("<nome arquivo chave privada>.key") If ($bSuccess = False) Then ConsoleWrite("Failed to load <nome" & @CRLF) Exit EndIf $oPrivKey = ObjCreate("Chilkat.PrivateKey") $bSuccess = $oPrivKey.LoadAnyFormat($oBdPrivKey,"") If ($bSuccess = False) Then ConsoleWrite($oPrivKey.LastErrorText & @CRLF) Exit EndIf $bSuccess = $oCert.SetPrivateKey($oPrivKey) If ($bSuccess = False) Then ConsoleWrite($oCert.LastErrorText & @CRLF) Exit EndIf $bSuccess = $oHttp.SetSslClientCert($oCert) If ($bSuccess = False) Then ConsoleWrite($oHttp.LastErrorText & @CRLF) Exit EndIf $oReq = ObjCreate("Chilkat.HttpRequest") $oReq.HttpVerb = "POST" $oReq.Path = "/oauth/v2/token" $oReq.ContentType = "application/x-www-form-urlencoded" $oReq.AddParam "grant_type","client_credentials" ; Requested scopes in OAuth2 are typically SPACE separated. $oReq.AddParam "scope","boleto-cobranca.read boleto-cobranca.write" $oReq.AddHeader "accept","application/json" Local $oResp = $oHttp.PostUrlEncoded("https://cdpj.partners.bancointer.com.br/oauth/v2/token",$oReq) If ($oHttp.LastMethodSuccess = False) Then ConsoleWrite($oHttp.LastErrorText & @CRLF) Exit EndIf $oJResp = ObjCreate("Chilkat.JsonObject") $oResp.GetBodyJson($oJResp) $oJResp.EmitCompact = False ConsoleWrite("Response Body:" & @CRLF) ConsoleWrite($oJResp.Emit() & @CRLF) Local $iRespStatusCode = $oResp.StatusCode ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF) If ($iRespStatusCode >= 400) Then ConsoleWrite("Response Header:" & @CRLF) ConsoleWrite($oResp.Header & @CRLF) ConsoleWrite("Failed." & @CRLF) Exit EndIf $bSuccess = $oJResp.WriteFile("qa_data/tokens/banco_inter_client_credentials.json") If ($bSuccess = False) Then ConsoleWrite("Failed to save JSON access token file." & @CRLF) Exit EndIf ConsoleWrite("Success." & @CRLF) |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.