-
Notifications
You must be signed in to change notification settings - Fork 0
/
1d3a6804.43449d16.js
1 lines (1 loc) · 34.1 KB
/
1d3a6804.43449d16.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[27],{128:function(e,t,n){"use strict";n.r(t),n.d(t,"frontMatter",(function(){return l})),n.d(t,"metadata",(function(){return s})),n.d(t,"rightToc",(function(){return b})),n.d(t,"default",(function(){return p}));var a=n(2),i=n(6),o=(n(0),n(250)),r=n(257),c=n(258),l={id:"credenciais",title:"Credentials, Certificate and Authorization",hide_title:!0,sidebar_label:"Credentials, Certificate and Authorization"},s={id:"openFinance/credenciais",isDocsHomePage:!1,title:"Credentials, Certificate and Authorization",description:"Credentials, Certificate and Authorization",source:"@site/docs\\openFinance\\credenciais.md",permalink:"/documentation/docs/openFinance/credenciais",sidebar_label:"Credentials, Certificate and Authorization",sidebar:"someSidebar",previous:{title:"Introduction",permalink:"/documentation/docs/openFinance/Introduction"},next:{title:"Endpoints",permalink:"/documentation/docs/openFinance/endpoints"}},b=[{value:"Getting the application credentials",id:"getting-the-application-credentials",children:[]},{value:"Understanding the application scopes",id:"understanding-the-application-scopes",children:[]},{value:"Create an application or configure an existing one",id:"create-an-application-or-configure-an-existing-one",children:[]},{value:"Generating and converting the P12 certificate",id:"generating-and-converting-the-p12-certificate",children:[]},{value:"Base routes",id:"base-routes",children:[]},{value:"OAuth2 authentication",id:"oauth2-authentication",children:[]},{value:"Authorization",id:"authorization",children:[]},{value:"Confguring tests on Postman",id:"confguring-tests-on-postman",children:[]},{value:"1. Importing the Open Finance API Collection",id:"1-importing-the-open-finance-api-collection",children:[]},{value:"2. Creating an Environment",id:"2-creating-an-environment",children:[]},{value:"3. Setting the certificate in Postman",id:"3-setting-the-certificate-in-postman",children:[]},{value:"4. Assigning the Client_Id and Client_Secret in Postman",id:"4-assigning-the-client_id-and-client_secret-in-postman",children:[]},{value:"Get authorization",id:"get-authorization",children:[{value:"Examples of authorization using the certificate. P12",id:"examples-of-authorization-using-the-certificate-p12",children:[]}]}],u={rightToc:b};function p(e){var t=e.components,n=Object(i.a)(e,["components"]);return Object(o.b)("wrapper",Object(a.a)({},u,n,{components:t,mdxType:"MDXLayout"}),Object(o.b)("h1",{className:"titulo"},"Credentials, Certificate and Authorization"),Object(o.b)("div",{className:"subtitulo"},Object(o.b)("p",null,"Open Finance API credential, certificate, and authorization information."),Object(o.b)("p",null,"To integrate the open Finance API to your system or your platform, it is necessary to have a Gerencianet Digital Account."),Object(o.b)("p",null,"Don't have an account?"),Object(o.b)("a",{href:"https://app.gerencianet.com.br/#abrirconta",target:"_blank",alt:"Open your free account"},Object(o.b)("button",{type:"button",className:"buttonCTA buttonorange"},"Open your free account")),Object(o.b)("br",null),Object(o.b)("br",null),Object(o.b)("p",null,"Once you have access, you will be able to obtain the credentials and certificate needed to communicate with the Open Finance API."),Object(o.b)("p",null,"See below how to obtain credentials, certificates and details about the authorization and security of your integration with Gerencianet."),Object(o.b)("h3",{id:"getting-the-application-credentials"},"Getting the application credentials"),Object(o.b)("p",null,"An integrator can create as many applications as he wants. For each application, 2 pairs of ",Object(o.b)("code",null,"Client_Id")," and ",Object(o.b)("code",null,"Client_Secret")," keys are generated, one pair for use in the Production environment and the other for Homologation."),Object(o.b)("h3",{id:"understanding-the-application-scopes"},"Understanding the application scopes"),Object(o.b)("p",null,"When creating or editing an application in your Gerencianet Account, you will need to configure the scopes that the application will have access to. Choosing these scopes will define the actions that an application will be authorized to perform via API."),Object(o.b)("p",null,"The scopes available in the Gerencianet Account Opening API are listed below with their respective descriptions:"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},"gn.opb.participants.read")," - Permission to get the Open Finance participants;"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},"gn.opb.payment.pix.send")," - Permission to start Pix via Open Finance;"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},"gn.opb.config.write")," - Permission to write in the account's URL settings;"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},"gn.opb.config.read")," - Permission to read the account's URL settings;",Object(o.b)("br",null),Object(o.b)("br",null))),Object(o.b)("h3",{id:"create-an-application-or-configure-an-existing-one"},"Create an application or configure an existing one"),Object(o.b)("p",null,"To create a new application or configure an existing one, you can access the ",Object(o.b)("a",{href:"https://gerencianet.github.io/documentation/docs/PIX/Credentials#create-an-application-or-configure-an-existing-one"},"link"),"."),Object(o.b)("br",null),Object(o.b)("h3",{id:"generating-and-converting-the-p12-certificate"},"Generating and converting the P12 certificate"),Object(o.b)("p",null,"To generate a certificate and convert it, if necessary, you can access the ",Object(o.b)("a",{href:"https://gerencianet.github.io/documentation/docs/PIX/Credentials#generating-a-p12-certificate"},"link")),Object(o.b)("br",null),Object(o.b)("h3",{id:"base-routes"},"Base routes"),Object(o.b)("p",null,"Base route or base URL's for environments, use the route below to communicate your application with the production or homologation environment offered by Gerencianet."),Object(o.b)(r.a,{defaultValue:"production",values:[{label:"Production",value:"production"},{label:"Homologation",value:"homo"}],mdxType:"Tabs"},Object(o.b)(c.a,{value:"production",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json"}),' "URL": {\n "Production": "https://apis.gerencianet.com.br/"\n }\n'))),Object(o.b)(c.a,{value:"homo",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json"}),' "URL": {\n "Homologation": "https://apis-h.gerencianet.com.br/"\n }\n')))),Object(o.b)("h3",{id:"oauth2-authentication"},"OAuth2 authentication"),Object(o.b)("p",null,"The process to authenticate in the Gerencianet Payment API follows the ","[OAuth2]","((",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"http://oauth.net/2/"}),"http://oauth.net/2/"),") process, in this process, it is included the security certificate generated in your Gerencianet account. Through this, the OAuth2 authentication can access the authorizations of you application and authorize or deny the requests. "),Object(o.b)("p",null,"For more details regarding authentication with OAuth2, just click on the button below:"),Object(o.b)("a",{href:"https://gerencianet.com.br/pix/?utm_referrer=https%3A%2F%2Fdev.gerencianet.com.br%2F",target:"_blank",alt:"QUERO SER CLIENTE GERENCIANET"},Object(o.b)("button",{type:"button",className:"buttonCTA buttonorange"},"Authentication OAuth2")),Object(o.b)("br",null),Object(o.b)("br",null),Object(o.b)("h3",{id:"authorization"},"Authorization"),Object(o.b)("p",null,"The Payments API requires the use of a PFX(.p12) certificate that is generated in your Gerencianet account. The Auth2 provides an authorization mechanism called mutual Transport Layer Security (mTLS) through the certificate created in your Gerencianet account, this method adds another level of security to the requests between your application and the Gerencianet Payment API."),Object(o.b)("p",null,"For more details about the PFX(.p12) creation and the mTLS pattern, just click on the button below:"),Object(o.b)("a",{href:"https://gerencianet.com.br/pix/?utm_referrer=https%3A%2F%2Fdev.gerencianet.com.br%2F",target:"_blank",alt:"QUERO SER CLIENTE GERENCIANET"},Object(o.b)("button",{type:"button",className:"buttonCTA buttonorange"},"Authorization with mTLS")),Object(o.b)("br",null),Object(o.b)("br",null),Object(o.b)("h3",{id:"confguring-tests-on-postman"},"Confguring tests on Postman"),Object(o.b)("p",null,"To proceed with the Postman configuration step, you must have:"),Object(o.b)("ol",null,Object(o.b)("li",{parentName:"ol"},"A pair of ",Object(o.b)("inlineCode",{parentName:"li"},"Client_Id")," and ",Object(o.b)("inlineCode",{parentName:"li"},"Client_Secret")," credentials of an application registered in your Gerencianet Account;"),Object(o.b)("li",{parentName:"ol"},"A P12/PEM certificate generated in your Gerencianet account;"),Object(o.b)("li",{parentName:"ol"},"The Postman software installed on your computer (If you don't have it, ",Object(o.b)("a",{href:"https://www.postman.com/downloads/"},"click here ")," to download it);")),Object(o.b)("h3",{id:"1-importing-the-open-finance-api-collection"},"1. Importing the Open Finance API Collection"),Object(o.b)("p",null,"This is the ",Object(o.b)("a",{href:"https://documenter.getpostman.com/view/13574984/Uz5Dobw1"},"link "),"to our Collection that we will keep updated with the Gerencianet Account opening API endpoints."),Object(o.b)("a",{href:"https://documenter.getpostman.com/view/13574984/UyrDCurw",target:"_blank",alt:"QUERO SER CLIENTE GERENCIANET"},Object(o.b)("button",{type:"button",className:"buttonCTA buttonorange"},"Run in Postman")),Object(o.b)("br",null),Object(o.b)("br",null),Object(o.b)("ol",{start:2},Object(o.b)("li",{parentName:"ol"},"With Postman started, use the shortcut ",Object(o.b)("code",null,"Ctrl+O")," to open the import screen;"),Object(o.b)("li",{parentName:"ol"},"Select ",Object(o.b)("em",{parentName:"li"},"Collection")," file;"),Object(o.b)("li",{parentName:"ol"},"Click ",Object(o.b)("em",{parentName:"li"},"Import"))),Object(o.b)("a",{href:"/documentation/img/import-collection-postman.png",target:"_blank"},Object(o.b)("img",{src:"/documentation/img/import-collection-postman.png",alt:"Ilustra\xe7\xe3o do in\xedcio do processo de importa\xe7\xe3o"})),Object(o.b)("br",null),Object(o.b)("br",null),Object(o.b)("a",{href:"/documentation/img/2-import-collection-postman.png",target:"_blank"},Object(o.b)("img",{src:"/documentation/img/2-import-collection-postman.png",alt:"Ilustra\xe7\xe3o da importa\xe7\xe3o do arquivo"})),Object(o.b)("br",null),Object(o.b)("br",null),Object(o.b)("a",{href:"/documentation/img/3-import-collection-postman.png",target:"_blank"},Object(o.b)("img",{src:"/documentation/img/3-import-collection-postman.png",alt:"Ilustra\xe7\xe3o da etapa final da importa\xe7\xe3o"})),Object(o.b)("br",null),Object(o.b)("br",null),Object(o.b)("h3",{id:"2-creating-an-environment"},"2. Creating an Environment"),Object(o.b)("p",null,"Creating an ",Object(o.b)("em",{parentName:"p"},"Environment")," in Postman is necessary for some automations built into the collection to work. These automations are designed to make it easier for developers during testing."),Object(o.b)("p",null,"With them you need to request the authorization only once, and then the ",Object(o.b)("inlineCode",{parentName:"p"},"access_token")," is recorded as a Postman environment variable, available for use in subsequent requests."),Object(o.b)("p",null,"To create an Environment follow the steps below."),Object(o.b)("ol",null,Object(o.b)("li",{parentName:"ol"},"Use the ",Object(o.b)("inlineCode",{parentName:"li"},"Ctrl+N")," shortcut and select 'Environment';"),Object(o.b)("li",{parentName:"ol"},"Give a name specifying whether this Environment will be pointed to the production or homologation environment;"),Object(o.b)("li",{parentName:"ol"},"Create the variable ",Object(o.b)("inlineCode",{parentName:"li"},"gn-api-open-finance")," and in initial value enter the URL of the Production or Homologation Payment API;"),Object(o.b)("li",{parentName:"ol"},"Save your Environment;"),Object(o.b)("li",{parentName:"ol"},"Select the desired Environment, so Postman will understand the created variable.")),Object(o.b)("p",null,"The images below shows the steps above. As an example, an Environment was created for Gerencianet Open Finance API Production environment."),Object(o.b)("a",{href:"/documentation/img/1-config-env-postman.png",target:"_blank"},Object(o.b)("img",{src:"/documentation/img/1-config-env-postman.png",alt:"Criando um novo environment"}))," ",Object(o.b)("br",null),Object(o.b)("br",null),Object(o.b)("a",{href:"/documentation/img/2-config-env-postman.png",target:"_blank"},Object(o.b)("img",{src:"/documentation/img/2-config-env-postman.png",alt:"Configura\xe7\xf5es do environment"}))," ",Object(o.b)("br",null),Object(o.b)("br",null),Object(o.b)("h3",{id:"3-setting-the-certificate-in-postman"},"3. Setting the certificate in Postman"),Object(o.b)("p",null,"All requests made to the Gerencianet Payment API need the certificate generated in your Gerencianet account. Therefore, to help you testing Postman, follow the steps below to configure the certificate usage during requests automatically:"),Object(o.b)("ol",null,Object(o.b)("li",{parentName:"ol"},"Click the gear icon in the upper right corner of the Postman;"),Object(o.b)("li",{parentName:"ol"},'Then click "Settings" to open the settings;'),Object(o.b)("li",{parentName:"ol"},'In the top tab, click "Certificates";'),Object(o.b)("li",{parentName:"ol"},'Then click on "Add Certificate";'),Object(o.b)("li",{parentName:"ol"},'In the configuration window of the new certificate, fill the "Host" field with the Base Route of the environment to which the certificate belongs (Production or Homologation);'),Object(o.b)("li",{parentName:"ol"},'Use the "PFX File" field to tell Postman where your P12/PEM certificate file is located;'),Object(o.b)("li",{parentName:"ol"},'Finish by clicking "Add" to save your settings.')),Object(o.b)("p",null,"By following these steps, Postman will use the certificate for any requests made to the Host of the configured environment."),Object(o.b)("br",null),Object(o.b)("a",{href:"/documentation/img/1-add-cert-postman.png",target:"_blank"},Object(o.b)("img",{src:"/documentation/img/1-add-cert-postman.png",alt:"Acessando as configura\xe7\xf5es do Postman"}))," ",Object(o.b)("br",null),Object(o.b)("br",null),Object(o.b)("a",{href:"/documentation/img/2-add-cert-postman.png",target:"_blank"},Object(o.b)("img",{src:"/documentation/img/2-add-cert-postman.png",alt:"Adicionando um novo certificado no Postman"}))," ",Object(o.b)("br",null),Object(o.b)("br",null),Object(o.b)("a",{href:"/documentation/img/3-add-cert-postman.png",target:"_blank"},Object(o.b)("img",{src:"/documentation/img/3-add-cert-postman.png",alt:"Configura\xe7\xf5es do certificado"}))," ",Object(o.b)("br",null),Object(o.b)("br",null),Object(o.b)("h3",{id:"4-assigning-the-client_id-and-client_secret-in-postman"},"4. Assigning the Client_Id and Client_Secret in Postman"),Object(o.b)("p",null,"To complete the configuration of your Postman it is necessary to configure the credentials of an application of your Gerencianet account. These credentials are used for Basic Auth and to get the ",Object(o.b)("inlineCode",{parentName:"p"},"access_token")," from OAuth."),Object(o.b)("p",null,"Follow the steps below to include the credentials and perform your first test in the Pix Gerencianet API."),Object(o.b)("ol",null,Object(o.b)("li",{parentName:"ol"},"In the imported collection, navigate to the ",Object(o.b)("inlineCode",{parentName:"li"},"/oauth/token")," route and double-click to open;"),Object(o.b)("li",{parentName:"ol"},'Go to the "Authorization" menu and make sure that the "Type" (authorization type) is selected as "Basic Auth";'),Object(o.b)("li",{parentName:"ol"},'In the "username" and "password" fields fill with your application credentials, Client_Id and Client_Secret respectively;'),Object(o.b)("li",{parentName:"ol"},'To test, click the "Send" button to submit the request')),Object(o.b)("p",null,"The image below illustrates the steps above. If everything was followed correctly, you should get a response in JSON format, containing the ",Object(o.b)("inlineCode",{parentName:"p"},"access_token"),", ",Object(o.b)("inlineCode",{parentName:"p"},"token_type"),", ",Object(o.b)("inlineCode",{parentName:"p"},"expires_in")," e ",Object(o.b)("inlineCode",{parentName:"p"},"scope")," (like the image bellow)."),Object(o.b)("a",{href:"/documentation/img/1-request-auth-postman.png",target:"_blank"},Object(o.b)("img",{src:"/documentation/img/1-request-auth-postman.png",alt:"Uso das credenciais de uma aplica\xe7\xe3o para autoriza\xe7\xe3o de requisi\xe7\xf5es"})),Object(o.b)("h2",{id:"get-authorization"},"Get authorization"),Object(o.b)("div",{class:"gn-endpoint"},Object(o.b)("span",{class:"http-method post"},"POST"),Object(o.b)("span",{class:"endpoint"},"/oauth/token")),Object(o.b)("br",null),Object(o.b)("p",null,"This endpoint is used to authorize an application's credentials and get the scopes that the application has to access the other API endpoints. The P12/PEM certificate must be present in the authorization request for the handshake with the API server to be allowed."),Object(o.b)("h3",{id:"examples-of-authorization-using-the-certificate-p12"},"Examples of authorization using the certificate. P12"),Object(o.b)("p",null,"To use the Gerencianet Payment API, the client and server must communicate on a verified connection to each other. Verification is done by the two-way certificate (.PEM or .P12), that is, the server and client have implemented a private key certificate and a public key certificate that allows one to ensure the identity of the other."),Object(o.b)("p",null,"Therefore to make any HTTP request to the Open Finance API, including the authorization request with OAuth2, it is necessary the certificate .P12, or .pem, in the request headers."),Object(o.b)("p",null,"Below are examples of how to consume the Authorization of the Gerencianet Open Finance API by incorporating this certificate into the request."),Object(o.b)(r.a,{defaultValue:"php",values:[{label:"php",value:"php"},{label:"Node",value:"Node"},{label:"Python",value:"Python"},{label:"C#",value:"C#"},{label:"Ruby",value:"Ruby"},{label:"Java",value:"Java"},{label:"Go",value:"Go"}],mdxType:"Tabs"},Object(o.b)(c.a,{value:"php",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-php"}),'<?php //Desenvolvido pela Consultoria T\xe9cnica da Gerencianet\n\n$config = [\n "certificado" => "./certificado.pem",\n "client_id" => "YOUR-CLIENT-ID",\n "client_secret" => "YOUR-CLIENT-SECRET"\n];\n$autorizacao = base64_encode($config["client_id"] . ":" . $config["client_secret"]);\n\n$curl = curl_init();\n\ncurl_setopt_array($curl, array(\n CURLOPT_URL => "https://apis.gerencianet.com.br/oauth/token", // Rota base, homologa\xe7\xe3o ou produ\xe7\xe3o\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => "",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 0,\n CURLOPT_FOLLOWLOCATION => true,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => "POST",\n CURLOPT_POSTFIELDS => \'{"grant_type": "client_credentials"}\',\n CURLOPT_SSLCERT => $config["certificado"], // Caminho do certificado\n CURLOPT_SSLCERTPASSWD => "",\n CURLOPT_HTTPHEADER => array(\n "Authorization: Basic $autorizacao",\n "Content-Type: application/json"\n ),\n));\n\n$response = curl_exec($curl);\n\ncurl_close($curl);\n\necho "<pre>";\necho $response;\necho "</pre>";\n'))),Object(o.b)(c.a,{value:"Node",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),'//Desenvolvido pela Consultoria T\xe9cnica da Gerencianet\n\n"use strict";\nconst https = require("https");\nvar axios = require("axios");\nvar fs = require("fs");\n\n//Insira o caminho de seu certificado .p12 dentro de seu projeto\nvar certificado = fs.readFileSync("./certificado.p12");\n\n//Insira os valores de suas credenciais em desenvolvimento do pix\nvar credenciais = {\n client_id: "YOUR-CLIENT-ID",\n client_secret: "YOUR-CLIENT-SECRET",\n};\n\nvar data = JSON.stringify({ grant_type: "client_credentials" });\nvar data_credentials = credenciais.client_id + ":" + credenciais.client_secret;\n\n// Codificando as credenciais em base64\nvar auth = Buffer.from(data_credentials).toString("base64");\n\nconst agent = new https.Agent({\n pfx: certificado,\n passphrase: "",\n});\n//Consumo em desenvolvimento da rota post oauth/token\nvar config = {\n method: "POST",\n url: "https://apis.gerencianet.com.br/oauth/token",\n headers: {\n Authorization: "Basic " + auth,\n "Content-Type": "application/json",\n },\n httpsAgent: agent,\n data: data,\n};\n\naxios(config)\n .then(function (response) {\n console.log(JSON.stringify(response.data));\n })\n .catch(function (error) {\n console.log(error);\n });\n'))),Object(o.b)(c.a,{value:"Python",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-py"}),'#Desenvolvido pela Consultoria T\xe9cnica da Gerencianet\n\nimport requests\nimport base64\n\ncredentials = {\n "client_id": "YOUR-CLIENT-ID",\n "client_secret": "YOUR-CLIENT-SECRET",\n}\n\ncertificado = \'./certificado.pem\' # A vari\xe1vel certificado \xe9 o diret\xf3rio em que seu certificado em formato .pem deve ser inserido\n\nauth = base64.b64encode(\n (f"{credentials[\'client_id\']}:{credentials[\'client_secret\']}"\n ).encode()).decode()\n\nurl = "https://apis.gerencianet.com.br/oauth/token" #Para ambiente de Desenvolvimento\n\npayload="{\\r\\n \\"grant_type\\": \\"client_credentials\\"\\r\\n}"\nheaders = {\n \'Authorization\': f"Basic {auth}",\n \'Content-Type\': \'application/json\'\n}\n\nresponse = requests.request("POST",\n url,\n headers=headers,\n data=payload,\n cert=certificado)\n\nprint(response.text)\n'))),Object(o.b)(c.a,{value:"C#",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),'//Desenvolvido pela Consultoria T\xe9cnica da Gerencianet\n\nusing System;\nusing System.Security.Cryptography.X509Certificates;\nusing System.Collections.Generic;\nusing RestSharp;\n\nnamespace PixGerencianet\n{\n class Authorize\n {\n public static string Base64Encode(string plainText)\n {\n var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);\n return System.Convert.ToBase64String(plainTextBytes);\n }\n\n static void Main(string[] args)\n {\n\n var credencials = new Dictionary<string, string>{\n {"client_id", "YOUR-CLIENT-ID"},\n {"client_secret", "YOUR-CLIENT-SECRET"}\n };\n var authorization = Base64Encode(credencials["client_id"] + ":" + credencials["client_secret"]);\n var client = new RestSharp.RestClient("https://apis.gerencianet.com.br/oauth/token");\n var request = new RestRequest(Method.POST);\n\n X509Certificate2 uidCert = new X509Certificate2("./certificado.p12", "");\n client.ClientCertificates = new X509CertificateCollection() { uidCert };\n\n request.AddHeader("Authorization", "Basic " + authorization);\n request.AddHeader("Content-Type", "application/json");\n request.AddParameter("application/json", "{\\r\\n \\"grant_type\\": \\"client_credentials\\"\\r\\n}", ParameterType.RequestBody);\n \n IRestResponse restResponse = client.Execute(request);\n string response = restResponse.Content;\n\n Console.WriteLine(response);\n }\n }\n}\n'))),Object(o.b)(c.a,{value:"Ruby",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),'#Desenvolvido pela Consultoria T\xe9cnica da Gerencianet\n\nrequire "uri"\nrequire "net/http"\nrequire "openssl"\n\nclient_id = "YOUR-CLIENT-ID";\nclient_secret = "YOUR-CLIENT-SECRET";\n\ncertfile = File.read("certificado.pem") # A vari\xe1vel certfile \xe9 o diret\xf3rio em que seu certificado em formato .pem deve ser inserido\n\nurl = URI("https://apis.gerencianet.com.br/oauth/token") #Para ambiente de Desenvolvimento\n\nhttps = Net::HTTP.new(url.host, url.port);\nhttps.use_ssl = true\nhttps.cert = OpenSSL::X509::Certificate.new(certfile)\nhttps.key = OpenSSL::PKey::RSA.new(certfile)\n\nrequest = Net::HTTP::Post.new(url)\nrequest.basic_auth(client_id, client_secret)\nrequest["Content-Type"] = "application/json"\nrequest.body = "{\\r\\n \\"grant_type\\": \\"client_credentials\\"\\r\\n}"\n\nresponse = https.request(request)\nputs response.read_body\n'))),Object(o.b)(c.a,{value:"Java",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-java"}),'//Desenvolvido pela Consultoria T\xe9cnica da Gerencianet\n\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.OutputStream;\nimport java.net.URL;\nimport java.util.Base64;\n\nimport javax.net.ssl.HttpsURLConnection;\nimport javax.net.ssl.SSLSocketFactory;\n\npublic class Auth {\n public static void main(String[] args) throws Exception {\n String client_id = "YOUR-CLIENT-ID";\n String client_secret = "YOUR-CLIENT-SECRET";;\n String basicAuth = Base64.getEncoder().encodeToString(((client_id+\':\'+client_secret).getBytes()));\n \n //Diret\xf3rio em que seu certificado em formato .p12 deve ser inserido\n System.setProperty("javax.net.ssl.keyStore", "certificado.p12"); \n SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();\n \n URL url = new URL ("https://apis.gerencianet.com.br/oauth/token"); //Para ambiente de Desenvolvimento \n HttpsURLConnection conn = (HttpsURLConnection)url.openConnection();\n conn.setDoOutput(true);\n conn.setRequestMethod("POST");\n conn.setRequestProperty("Content-Type", "application/json");\n conn.setRequestProperty("Authorization", "Basic "+ basicAuth);\n conn.setSSLSocketFactory(sslsocketfactory);\n String input = "{\\"grant_type\\": \\"client_credentials\\"}";\n \n OutputStream os = conn.getOutputStream();\n os.write(input.getBytes());\n os.flush(); \n\n InputStreamReader reader = new InputStreamReader(conn.getInputStream());\n BufferedReader br = new BufferedReader(reader);\n\n String response;\n while ((response = br.readLine()) != null) {\n System.out.println(response);\n }\n conn.disconnect();\n\n }\n}\n'))),Object(o.b)(c.a,{value:"Go",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-go"}),'//Desenvolvido pela Consultoria T\xe9cnica da Gerencianet\npackage main\n\nimport (\n "fmt"\n "strings"\n "net/http"\n "io/ioutil"\n "crypto/tls"\n)\n\nconst(\n client_id = "YOUR-CLIENT-ID"\n client_secret = "YOUR-CLIENT-SECRET"\n)\n\nfunc main() {\n\n url := "https://apis.gerencianet.com.br/oauth/token"// Rota base, homologa\xe7\xe3o ou produ\xe7\xe3o\n method := "POST"\n\n payload := strings.NewReader(`{"grant_type": "client_credentials"}`)\n\n\n cert, _ := tls.LoadX509KeyPair("CA.crt.pem", "KEY.crt.pem")// Seu certificado e chave privada gerada a partir dos comandos de convers\xe3o OpenSSL\n\n client := &http.Client{\n Transport: &http.Transport{\n TLSClientConfig: &tls.Config{\n Certificates: []tls.Certificate{cert},\n },\n },\n}\n\n req, err := http.NewRequest(method, url, payload)\n\n if err != nil {\n fmt.Println(err)\n return\n }\n req.SetBasicAuth(client_id, client_secret)\n req.Header.Add("Content-Type", "application/json")\n\n res, err := client.Do(req)\n if err != nil {\n fmt.Println(err)\n return\n }\n defer res.Body.Close()\n\n body, err := ioutil.ReadAll(res.Body)\n if err != nil {\n fmt.Println(err)\n return\n }\n fmt.Println(string(body))\n}\n')))),Object(o.b)("b",null,"Authorization example of response"),Object(o.b)("br",null),"The code snippet below represents an example of OAuth's response to your authorization request.",Object(o.b)(r.a,{defaultValue:"response",values:[{label:"Response",value:"response"}],mdxType:"Tabs"},Object(o.b)(c.a,{value:"response",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json"}),'{\n "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",\n "token_type": "Bearer",\n "expires_in": 3600,\n "scope": "gn.opb.paticipants.read gn.opb.pix.send gn.opb.config.write gn.opb.config.read"\n}\n')))),Object(o.b)("p",null,"The table below describes the attributes present in the returned JSON."),Object(o.b)("table",null,Object(o.b)("tbody",null,Object(o.b)("tr",null,Object(o.b)("th",null,"Attribute"),Object(o.b)("th",{align:"center"},"Description"),Object(o.b)("th",{align:"center"},"Type")),Object(o.b)("tr",null,Object(o.b)("td",null,Object(o.b)("b",null,"access_token")),Object(o.b)("td",{align:"left"}," Authorization token to be used in other requests made to the API."),Object(o.b)("td",{align:"center"},"String")),Object(o.b)("tr",null,Object(o.b)("td",null,Object(o.b)("b",null,"token_type")),Object(o.b)("td",{align:"left"}," Authorization type in which access_token should be used ",Object(o.b)("br",null),Object(o.b)("br",null),'Default: "Bearer"'),Object(o.b)("td",{align:"center"},"String")),Object(o.b)("tr",null,Object(o.b)("td",null,Object(o.b)("b",null,"expires_in")),Object(o.b)("td",{align:"left"}," access_token expiration time in seconds. ",Object(o.b)("br",null),Object(o.b)("br",null),"Default: 3600"),Object(o.b)("td",{align:"center"},"Integer (int32)")),Object(o.b)("tr",null,Object(o.b)("td",null,Object(o.b)("b",null,"scope")),Object(o.b)("td",{align:"left"}," List of scopes to which the authorized application has access. Scopes are space-separated."),Object(o.b)("td",{align:"center"},"String"))))))}p.isMDXComponent=!0},250:function(e,t,n){"use strict";n.d(t,"a",(function(){return u})),n.d(t,"b",(function(){return h}));var a=n(0),i=n.n(a);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){o(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e,t){if(null==e)return{};var n,a,i=function(e,t){if(null==e)return{};var n,a,i={},o=Object.keys(e);for(a=0;a<o.length;a++)n=o[a],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a<o.length;a++)n=o[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var s=i.a.createContext({}),b=function(e){var t=i.a.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):c(c({},t),e)),n},u=function(e){var t=b(e.components);return i.a.createElement(s.Provider,{value:t},e.children)},p={inlineCode:"code",wrapper:function(e){var t=e.children;return i.a.createElement(i.a.Fragment,{},t)}},d=i.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,o=e.originalType,r=e.parentName,s=l(e,["components","mdxType","originalType","parentName"]),u=b(n),d=a,h=u["".concat(r,".").concat(d)]||u[d]||p[d]||o;return n?i.a.createElement(h,c(c({ref:t},s),{},{components:n})):i.a.createElement(h,c({ref:t},s))}));function h(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var o=n.length,r=new Array(o);r[0]=d;var c={};for(var l in t)hasOwnProperty.call(t,l)&&(c[l]=t[l]);c.originalType=e,c.mdxType="string"==typeof e?e:a,r[1]=c;for(var s=2;s<o;s++)r[s]=n[s];return i.a.createElement.apply(null,r)}return i.a.createElement.apply(null,n)}d.displayName="MDXCreateElement"},254:function(e,t,n){"use strict";function a(e){var t,n,i="";if("string"==typeof e||"number"==typeof e)i+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=a(e[t]))&&(i&&(i+=" "),i+=n);else for(t in e)e[t]&&(i&&(i+=" "),i+=t);return i}t.a=function(){for(var e,t,n=0,i="";n<arguments.length;)(e=arguments[n++])&&(t=a(e))&&(i&&(i+=" "),i+=t);return i}},255:function(e,t,n){"use strict";var a=n(0);const i=Object(a.createContext)({tabGroupChoices:{},setTabGroupChoices:()=>{},isAnnouncementBarClosed:!1,closeAnnouncementBar:()=>{}});t.a=i},256:function(e,t,n){"use strict";var a=n(0),i=n(255);t.a=function(){return Object(a.useContext)(i.a)}},257:function(e,t,n){"use strict";var a=n(0),i=n.n(a),o=n(256),r=n(254),c=n(92),l=n.n(c);const s=37,b=39;t.a=function(e){const{block:t,children:n,defaultValue:c,values:u,groupId:p}=e,{tabGroupChoices:d,setTabGroupChoices:h}=Object(o.a)(),[m,g]=Object(a.useState)(c);if(null!=p){const e=d[p];null!=e&&e!==m&&u.some(t=>t.value===e)&&g(e)}const O=e=>{g(e),null!=p&&h(p,e)},f=[];return i.a.createElement("div",null,i.a.createElement("ul",{role:"tablist","aria-orientation":"horizontal",className:Object(r.a)("tabs",{"tabs--block":t})},u.map(({value:e,label:t})=>i.a.createElement("li",{role:"tab",tabIndex:"0","aria-selected":m===e,className:Object(r.a)("tabs__item",l.a.tabItem,{"tabs__item--active":m===e}),key:e,ref:e=>f.push(e),onKeyDown:e=>((e,t,n)=>{switch(n.keyCode){case b:((e,t)=>{const n=e.indexOf(t)+1;e[n]?e[n].focus():e[0].focus()})(e,t);break;case s:((e,t)=>{const n=e.indexOf(t)-1;e[n]?e[n].focus():e[e.length-1].focus()})(e,t)}})(f,e.target,e),onFocus:()=>O(e),onClick:()=>O(e)},t))),i.a.createElement("div",{role:"tabpanel",className:"margin-vert--md"},a.Children.toArray(n).filter(e=>e.props.value===m)[0]))}},258:function(e,t,n){"use strict";var a=n(0),i=n.n(a);t.a=function(e){return i.a.createElement("div",null,e.children)}}}]);