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
(Visual FoxPro) 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
LOCAL loHttp LOCAL lnSuccess LOCAL loCert LOCAL loBdPrivKey LOCAL loPrivKey LOCAL loReq LOCAL loResp LOCAL loJResp LOCAL lnRespStatusCode * This example assumes the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http') loHttp = CreateObject('Chilkat.Http') * First load the certificate and private key, and set as the HTTP object's client certificate. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Cert') loCert = CreateObject('Chilkat.Cert') lnSuccess = loCert.LoadFromFile("<nome arquivo certificado>.crt") IF (lnSuccess = 0) THEN ? loCert.LastErrorText RELEASE loHttp RELEASE loCert CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.BinData') loBdPrivKey = CreateObject('Chilkat.BinData') lnSuccess = loBdPrivKey.LoadFile("<nome arquivo chave privada>.key") IF (lnSuccess = 0) THEN ? "Failed to load <nome" RELEASE loHttp RELEASE loCert RELEASE loBdPrivKey CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.PrivateKey') loPrivKey = CreateObject('Chilkat.PrivateKey') lnSuccess = loPrivKey.LoadAnyFormat(loBdPrivKey,"") IF (lnSuccess = 0) THEN ? loPrivKey.LastErrorText RELEASE loHttp RELEASE loCert RELEASE loBdPrivKey RELEASE loPrivKey CANCEL ENDIF lnSuccess = loCert.SetPrivateKey(loPrivKey) IF (lnSuccess = 0) THEN ? loCert.LastErrorText RELEASE loHttp RELEASE loCert RELEASE loBdPrivKey RELEASE loPrivKey CANCEL ENDIF lnSuccess = loHttp.SetSslClientCert(loCert) IF (lnSuccess = 0) THEN ? loHttp.LastErrorText RELEASE loHttp RELEASE loCert RELEASE loBdPrivKey RELEASE loPrivKey CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.HttpRequest') loReq = CreateObject('Chilkat.HttpRequest') loReq.HttpVerb = "POST" loReq.Path = "/oauth/v2/token" loReq.ContentType = "application/x-www-form-urlencoded" loReq.AddParam("grant_type","client_credentials") * Requested scopes in OAuth2 are typically SPACE separated. loReq.AddParam("scope","boleto-cobranca.read boleto-cobranca.write") loReq.AddHeader("accept","application/json") loResp = loHttp.PostUrlEncoded("https://cdpj.partners.bancointer.com.br/oauth/v2/token",loReq) IF (loHttp.LastMethodSuccess = 0) THEN ? loHttp.LastErrorText RELEASE loHttp RELEASE loCert RELEASE loBdPrivKey RELEASE loPrivKey RELEASE loReq CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJResp = CreateObject('Chilkat.JsonObject') loResp.GetBodyJson(loJResp) loJResp.EmitCompact = 0 ? "Response Body:" ? loJResp.Emit() lnRespStatusCode = loResp.StatusCode ? "Response Status Code = " + STR(lnRespStatusCode) IF (lnRespStatusCode >= 400) THEN ? "Response Header:" ? loResp.Header ? "Failed." RELEASE loResp RELEASE loHttp RELEASE loCert RELEASE loBdPrivKey RELEASE loPrivKey RELEASE loReq RELEASE loJResp CANCEL ENDIF RELEASE loResp lnSuccess = loJResp.WriteFile("qa_data/tokens/banco_inter_client_credentials.json") IF (lnSuccess = 0) THEN ? "Failed to save JSON access token file." RELEASE loHttp RELEASE loCert RELEASE loBdPrivKey RELEASE loPrivKey RELEASE loReq RELEASE loJResp CANCEL ENDIF ? "Success." RELEASE loHttp RELEASE loCert RELEASE loBdPrivKey RELEASE loPrivKey RELEASE loReq RELEASE loJResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.