![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Visual Basic 6.0) Banco Inter OAuth2 Client CredentialsGenerate an OAuth2 access token needed to consume the Inter APIs. Note: This example requires Chilkat v11.0.0 or greater. For more information, see https://developers.bancointer.com.br/reference/token-3
Dim success As Long success = 0 ' This example assumes the Chilkat API to have been previously unlocked. ' See Global Unlock Sample for sample code. Dim http As New ChilkatHttp ' First load the certificate and private key, and set as the HTTP object's client certificate. Dim cert As New ChilkatCert success = cert.LoadFromFile("<nome arquivo certificado>.crt") If (success = 0) Then Debug.Print cert.LastErrorText Exit Sub End If Dim bdPrivKey As New ChilkatBinData success = bdPrivKey.LoadFile("<nome arquivo chave privada>.key") If (success = 0) Then Debug.Print "Failed to load <nome" Exit Sub End If Dim privKey As New PrivateKey success = privKey.LoadAnyFormat(bdPrivKey,"") If (success = 0) Then Debug.Print privKey.LastErrorText Exit Sub End If success = cert.SetPrivateKey(privKey) If (success = 0) Then Debug.Print cert.LastErrorText Exit Sub End If success = http.SetSslClientCert(cert) If (success = 0) Then Debug.Print http.LastErrorText Exit Sub End If Dim req As New ChilkatHttpRequest req.HttpVerb = "POST" req.Path = "/oauth/v2/token" req.ContentType = "application/x-www-form-urlencoded" req.AddParam "grant_type","client_credentials" ' Requested scopes in OAuth2 are typically SPACE separated. req.AddParam "scope","boleto-cobranca.read boleto-cobranca.write" req.AddHeader "accept","application/json" Dim resp As New ChilkatHttpResponse success = http.HttpReq("https://cdpj.partners.bancointer.com.br/oauth/v2/token",req,resp) If (success = 0) Then Debug.Print http.LastErrorText Exit Sub End If Dim jResp As New ChilkatJsonObject success = resp.GetBodyJson(jResp) jResp.EmitCompact = 0 Debug.Print "Response Body:" Debug.Print jResp.Emit() Dim respStatusCode As Long respStatusCode = resp.StatusCode Debug.Print "Response Status Code = " & respStatusCode If (respStatusCode >= 400) Then Debug.Print "Response Header:" Debug.Print resp.Header Debug.Print "Failed." Exit Sub End If success = jResp.WriteFile("qa_data/tokens/banco_inter_client_credentials.json") If (success = 0) Then Debug.Print "Failed to save JSON access token file." Exit Sub End If Debug.Print "Success." |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.