-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path904d15d5.6420f79d.js
1 lines (1 loc) · 50.7 KB
/
904d15d5.6420f79d.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[87],{187:function(e,t,n){"use strict";n.r(t),n.d(t,"frontMatter",(function(){return s})),n.d(t,"metadata",(function(){return l})),n.d(t,"rightToc",(function(){return b})),n.d(t,"default",(function(){return d}));var a=n(2),i=n(6),o=(n(0),n(250)),r=n(257),c=n(258),s={id:"Credentials",title:"Credentials",hide_title:!0,sidebar_label:"Credentials, Certified and Authorization"},l={id:"PIX/Credentials",isDocsHomePage:!1,title:"Credentials",description:"Credentials, Certificate and Authorization",source:"@site/docs\\PIX\\credentials.md",permalink:"/documentation/docs/PIX/Credentials",sidebar_label:"Credentials, Certified and Authorization",sidebar:"someSidebar",previous:{title:"Introduction",permalink:"/documentation/docs/PIX/Introduction"},next:{title:"Endpoints",permalink:"/documentation/docs/PIX/Endpoints"}},b=[{value:"Getting application credentials",id:"getting-application-credentials",children:[{value:"Understanding application's scopes",id:"understanding-applications-scopes",children:[]},{value:"Create an application or configure an existing one",id:"create-an-application-or-configure-an-existing-one",children:[]}]},{value:"Generating a P12 certificate",id:"generating-a-p12-certificate",children:[{value:"Conversion of P12 certificate to PEM format",id:"conversion-of-p12-certificate-to-pem-format",children:[]}]},{value:"Base routes",id:"base-routes",children:[]},{value:"Authorization with OAuth2",id:"authorization-with-oauth2",children:[]},{value:"Setting Postman for tests",id:"setting-postman-for-tests",children:[{value:"1. Importing the Pix API Collection",id:"1-importing-the-pix-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:"Obtaining the Authorization",id:"obtaining-the-authorization",children:[{value:"Examples of authorization using the certificate. P12",id:"examples-of-authorization-using-the-certificate-p12",children:[]},{value:"Examples of authorization responses",id:"examples-of-authorization-responses",children:[]}]}],p={rightToc:b};function d(e){var t=e.components,n=Object(i.a)(e,["components"]);return Object(o.b)("wrapper",Object(a.a)({},p,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,"To integrate the Gerencianet's Pix API to your system or platform, you must have a Digital Gerencianet Account."),Object(o.b)("p",null,"Don't have a account?"),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"},"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 ",Object(o.b)("strong",{parentName:"p"},"credentials and certificate")," needed to communicate with the Pix Gerencianet API."),Object(o.b)("p",null,"See below how to obtain the credentials, certificates and details about the authorization and security of your integration with Gerencianet."),Object(o.b)("br",null),Object(o.b)("h2",{id:"getting-application-credentials"},"Getting application credentials"),Object(o.b)("hr",null),Object(o.b)("p",null,"An integrator can create as many applications as he wants. For each application, 2 pairs of keys ",Object(o.b)("inlineCode",{parentName:"p"},"Client_Id")," and ",Object(o.b)("inlineCode",{parentName:"p"},"Client_Secret")," are generated, one pair for use in a Production environment (",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://s3.amazonaws.com/gerencianet-pub-prod-1/printscreen/2021/02/25/matheus.rodrigues/95259b-d6f94497-7d4b-4317-8546-f8a2f24d9ac3.png"}),"?"),") and the other for Homologation (",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://s3.amazonaws.com/gerencianet-pub-prod-1/printscreen/2021/02/25/matheus.rodrigues/198990-b5128a5c-3682-4025-867d-dd9e72e10b5f.png"}),"?"),")."),Object(o.b)("p",null,"Using the Gerencianet's Pix API, the integrator can generate Pix transactions (payments and receipts), configure Webhooks to receive notifications via callbacks and access exclusive features of the Digital Gerencianet Account."),Object(o.b)("br",null),Object(o.b)("h3",{id:"understanding-applications-scopes"},"Understanding application's 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. The choice of these scopes defines which actions an application will be ",Object(o.b)("strong",{parentName:"p"},"authorized")," to perform via API."),Object(o.b)("p",null,"The scopes available in the Gerencianet's Pix 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"},Object(o.b)("inlineCode",{parentName:"strong"},"cob.write"))," - Permission to ",Object(o.b)("strong",{parentName:"li"},"alteration of charges"),";"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},Object(o.b)("inlineCode",{parentName:"strong"},"cob.read"))," - Permission to ",Object(o.b)("strong",{parentName:"li"},"charge consultation"),";"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},Object(o.b)("inlineCode",{parentName:"strong"},"pix.write"))," - Permission to ",Object(o.b)("strong",{parentName:"li"},"alteration of Pix"),";"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},Object(o.b)("inlineCode",{parentName:"strong"},"pix.read"))," - Permission to ",Object(o.b)("strong",{parentName:"li"},"Pix consultation"),";"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},Object(o.b)("inlineCode",{parentName:"strong"},"pix.send"))," - Permission to ",Object(o.b)("strong",{parentName:"li"},"request sending pix"),";"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},Object(o.b)("inlineCode",{parentName:"strong"},"webhook.write"))," - Permission to ",Object(o.b)("strong",{parentName:"li"},"alteration of webhook"),";"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},Object(o.b)("inlineCode",{parentName:"strong"},"webhook.read"))," - Permission to ",Object(o.b)("strong",{parentName:"li"},"webhook consultation"),";"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},Object(o.b)("inlineCode",{parentName:"strong"},"payloadlocation.write"))," - Permission to ",Object(o.b)("strong",{parentName:"li"},"create payload location"),";"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},Object(o.b)("inlineCode",{parentName:"strong"},"payloadlocation.read"))," - Permission to ",Object(o.b)("strong",{parentName:"li"},"location consultation"),";"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},Object(o.b)("inlineCode",{parentName:"strong"},"gn.pix.evp.write"))," - Permission to ",Object(o.b)("strong",{parentName:"li"},"create/remove key evp"),";"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},Object(o.b)("inlineCode",{parentName:"strong"},"gn.pix.evp.read"))," - Permission to ",Object(o.b)("strong",{parentName:"li"},"list key evp"),";"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},Object(o.b)("inlineCode",{parentName:"strong"},"gn.balance.read"))," - Permission to ",Object(o.b)("strong",{parentName:"li"},"fetch account balance"),";"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},Object(o.b)("inlineCode",{parentName:"strong"},"gn.settings.write"))," - Permission to ",Object(o.b)("strong",{parentName:"li"},"create/modify account settings"),";"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},Object(o.b)("inlineCode",{parentName:"strong"},"gn.settings.read"))," - Permission to ",Object(o.b)("strong",{parentName:"li"},"list account settings"),"."),Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},Object(o.b)("inlineCode",{parentName:"strong"},"gn.reports.write"))," - Permission to ",Object(o.b)("strong",{parentName:"li"},"request reconciliation extract"),"."),Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},Object(o.b)("inlineCode",{parentName:"strong"},"gn.reports.read"))," - Permission to ",Object(o.b)("strong",{parentName:"li"},"download reconciliation extract"),".")),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,"See how to create an application or take advantage of an existing application to integrate with the Gerencianet's Pix API."),Object(o.b)(r.a,{defaultValue:"saida",values:[{label:"Create application",value:"saida"},{label:"Take advantage of an already registered application",value:"2"}],mdxType:"Tabs"},Object(o.b)(c.a,{value:"saida",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json"}),'To create an application to use the Pix API follow the steps below:\n\n1.Access your account and click on the item "API" on the top menu of the Gerencianet account;\n\n2.In the left menu, click on "My Applications" and "New Application"\n\n3. Enable the Pix API and choose the scopes you want to release in Production and Approval environment (you can edit them in the future);\n\n4.With the scopes selected, click on "Create new application".\n')),Object(o.b)("a",{href:"/documentation/img/1-create-app-pangeia.png",target:"_blank"},Object(o.b)("img",{src:"/documentation/img/1-create-app-pangeia.png",alt:"create-app-pangeia"}))),Object(o.b)(c.a,{value:"2",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json"}),'To take advantage of an application already registered in your account and use it to integrate with Pix, follow the steps below:\n\n1.Access your account and click on the item "API" on the top menu of the Gerencianet account;\n\n2.In the left menu, click on "My Applications". Then choose the application that will be edited and click "Edit" (orange button)\n\n3.Enable the Pix API and choose the scopes you want to release in Production and Approval environment (you can edit them whenever you want);\n\n4.With the scopes selected, click on "Update Application".\n')),Object(o.b)("a",{href:"/documentation/img/1-edit-app-pangeia.png",target:"_blank"},Object(o.b)("img",{src:"/documentation/img/1-edit-app-pangeia.png",alt:"edit-app-pangeia"})))),Object(o.b)("br",null),Object(o.b)("h2",{id:"generating-a-p12-certificate"},"Generating a P12 certificate"),Object(o.b)("p",null,"All requests must contain a security certificate that will be provided by Gerencianet within your account, in ",Object(o.b)("inlineCode",{parentName:"p"},"PFX(.p12)")," format. This requirement is fully described in the ",Object(o.b)("a",{href:"https://www.bcb.gov.br/estabilidadefinanceira/comunicacaodados",target:"_blank",alt:"manual de seguran\xe7a do pix"},"PIX security manual"),"."),Object(o.b)("p",null,"To generate your certificate, just follow the steps below:"),Object(o.b)("ol",null,Object(o.b)("li",{parentName:"ol"},'Access the item "API" in the upper menu of the Gerencianet account;'),Object(o.b)("li",{parentName:"ol"},'In the left menu, click on "My Certificates";'),Object(o.b)("li",{parentName:"ol"},"In the new window, select the environment to which the certificate will belong (Production or Homologation)"),Object(o.b)("li",{parentName:"ol"},'Click on "New Certificate" (orange button);'),Object(o.b)("li",{parentName:"ol"},"Assign a description to the certificate to identify it in the future;"),Object(o.b)("li",{parentName:"ol"},"Confirm the creation of the certificate;"),Object(o.b)("li",{parentName:"ol"},"Finally, download the certificate.")),Object(o.b)("p",null,"The steps for creating a certificate are illustrated in the image below."),Object(o.b)("a",{href:"/documentation/img/newCert.png",target:"_blank"},Object(o.b)("img",{src:"/documentation/img/newCert.png",alt:"Steps for creating the certificate"})),Object(o.b)("a",{href:"/documentation/img/createCert.png",target:"_blank"},Object(o.b)("img",{src:"/documentation/img/createCert.png",alt:"Certificate creation window"})),Object(o.b)("a",{href:"/documentation/img/downloadCert.png",target:"_blank"},Object(o.b)("img",{src:"/documentation/img/downloadCert.png",alt:"Generated certificate download window"})),Object(o.b)("div",{className:"admonition admonition-caution alert alert--warning"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})))),"caution")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"The certificate is downloaded immediately after its creation. You will not be able to download the same certificate at another time, so please store it in a safe place on your computer."))),Object(o.b)("br",null),Object(o.b)("p",null,"It is noteworthy that ",Object(o.b)("strong",{parentName:"p"},"the same certificate can be used by several applications")," of your digital account. Even so, you can generate up to five certificates for each environment (Production or Homologation)."),Object(o.b)("br",null),Object(o.b)("h3",{id:"conversion-of-p12-certificate-to-pem-format"},"Conversion of P12 certificate to PEM format"),Object(o.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"tip")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"In some languages keys will need to be converted to ",Object(o.b)("inlineCode",{parentName:"p"},".pem")," format. Use the information in this section only if this is the case for you."))),Object(o.b)("p",null,"EIn some programming languages you must convert the ",Object(o.b)("inlineCode",{parentName:"p"},".p12")," certificate to ",Object(o.b)("inlineCode",{parentName:"p"},".pem")," format. To convert your certificate, you can ",Object(o.b)("a",{href:"https://pix.gerencianet.com.br/ferramentas/conversorGerencianet.exe",target:"_blank",alt:"Conversor de certificados Gerencianet"},"download the certificate converter made available by Gerencianet"),"."),Object(o.b)("p",null,"You can also use the OpenSSL command to perform this format conversion between keys:"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"# Generate certificate and key in single file\nopenssl pkcs12 -in certificado.p12 -out certificado.pem -nodes\n")),Object(o.b)("p",null,"If it is necessary to separate the private key from the certificate during conversion, use the command below, also with OpenSSL:"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"# Generate separate certificate and key\nopenssl pkcs12 -in path.p12 -out newfile.crt.pem -clcerts -nokeys #certificado\nopenssl pkcs12 -in path.p12 -out newfile.key.pem -nocerts -nodes #private key\n")),Object(o.b)("div",{className:"admonition admonition-important alert alert--info"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"important")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"The certifcate conversion can ask for some ",Object(o.b)("strong",{parentName:"p"},"certificate password"),". If this happen, you should let it empty and send. "))),Object(o.b)("br",null),Object(o.b)("h2",{id:"base-routes"},"Base routes"),Object(o.b)("p",null,"In this documentation you will notice references to the Base Routes or BASE URL's for Production or Homologation environments. These routes are actually the URL in which the Pix Gerencianet API is located. Thus, when we refer to endpoints, it is implied that these URL snippets also make up the final route of the resource."),Object(o.b)("p",null,"Use the routes below to link your application with the production and homologation environments offered by Gerencianet."),Object(o.b)(r.a,{defaultValue:"sandbox",values:[{label:"Homologation",value:"sandbox"},{label:"Production",value:"production"}],mdxType:"Tabs"},Object(o.b)(c.a,{value:"sandbox",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json"}),' "URL": {\n "sandbox": "https://api-pix-h.gerencianet.com.br"\n }\n'))),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://api-pix.gerencianet.com.br"\n }\n')))),Object(o.b)("br",null),Object(o.b)("h2",{id:"authorization-with-oauth2"},"Authorization with OAuth2"),Object(o.b)("p",null,"The authorization mechanism for requests made to the Pix Gerencianet API is compatible with ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"http://oauth.net/2/"}),"OAuth 2.0 protocol"),". The purpose of OAuth2 is to obtain the access token (",Object(o.b)("inlineCode",{parentName:"p"},"access_token"),"). This ",Object(o.b)("inlineCode",{parentName:"p"},"access_token")," is used to authorize all calls made to the API, verifying if some particular application has permissions to consume the requested endpoint."),Object(o.b)("p",null,"The request authentication is made using HTTP ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://en.wikipedia.org/wiki/Basic_access_authentication"}),"Basic Auth")," from the ",Object(o.b)("inlineCode",{parentName:"p"},"Client_Id")," and ",Object(o.b)("inlineCode",{parentName:"p"},"Client_Secret")," of the application created in your Gerencianet account."),Object(o.b)("p",null,"Through this authentication, OAuth will be able to respond which authorizations has the application and, consequently, authorize or deny requests according to that information."),Object(o.b)("div",{className:"admonition admonition-caution alert alert--warning"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})))),"Caution!")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"The P12/PEM Certificate created in the previous steps ",Object(o.b)("strong",{parentName:"p"},"is required in all requests")," made to the Pix API, including the authorization request."))),Object(o.b)("br",null),Object(o.b)("h2",{id:"setting-postman-for-tests"},"Setting Postman for tests"),Object(o.b)("div",{className:"admonition admonition-important alert alert--info"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"important")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"The use of Postman software is optional. The next few paragraphs explain how to configure it. If you don't want to use Postman for testing, you can move on to the next topic: ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:""}),"Get Authorization"),"."))),Object(o.b)("p",null,"To proceed with the Postman configuration, 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 according to the previous steps;"),Object(o.b)("li",{parentName:"ol"},"The Postman software installed on your computer (If you don't have it, ",Object(o.b)("a",Object(a.a)({parentName:"li"},{href:"https://www.postman.com/downloads/"}),"clique here to download"),");")),Object(o.b)("br",null),Object(o.b)("h3",{id:"1-importing-the-pix-api-collection"},"1. Importing the Pix API Collection"),Object(o.b)("p",null,"When you have all of the above requirements, start setting up Postman by importing the ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://documenter.getpostman.com/view/13574984/TVzVgvBA"}),Object(o.b)("em",{parentName:"a"},"Pix Gerencianet API Collection")),"."),Object(o.b)("ol",null,Object(o.b)("li",{parentName:"ol"},"Download the JSON file from the collection ",Object(o.b)("a",{download:!0,href:"#",class:"lnk-collection-postman",target:"_blank"},"clicking here"),";"),Object(o.b)("li",{parentName:"ol"},"With Postman running, use the 'Ctrl+O' shortcut 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)("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)("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-pix")," and in initial value (",Object(o.b)("em",{parentName:"li"},"Initial value"),") enter the URL of the Production or Homologation Pix 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 Pix Gerencianet API Homologation environment."),Object(o.b)("div",{className:"admonition admonition-important alert alert--info"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"important")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"Repeat the steps above to this time have an Environment pointed to the Production environment. So you can simply switch between Environments and your requests will already be pointed correctly."))),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)("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 Pix Gerencianet 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)("div",{className:"admonition admonition-important alert alert--info"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"important")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"It is ideal for you to configure the certificate from the homologation environment, but you can also repeat the steps above to configure Postman with a certificate for the Production environment."))),Object(o.b)("p",null,"The images below illustrate the step-by-step configuration of the certificate."),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)("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)("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" 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)("br",null),Object(o.b)("br",null),Object(o.b)("h2",{id:"obtaining-the-authorization"},"Obtaining the 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 the credentials of an application and get the scopes that the application has to access the other API endpoints. The P12/PEM certificate must be in the authorization request in order to do the ",Object(o.b)("em",{parentName:"p"},"handshake")," with the API server to be allowed."),Object(o.b)("br",null),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 make HTTP requests using the certificates .P12 or .PEM for Pix authorization the key must be in the request."),Object(o.b)("p",null,"When using Pix it is necessary that the client and server to communicate on a verified connection with each other. The 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 Pix API, including the authorization request from OAuth2, it is necessary for the certificate .P12, or .PEM, to be present in the requisition headers."),Object(o.b)("p",null,"There are examples of how to consume Gerencianet Pix API authorization, incorporating this certificate into the request."),Object(o.b)(r.a,{defaultValue:"php",values:[{label:"PHP",value:"php"},{label:"Python",value:"python"},{label:"NodeJS",value:"js"},{label:"C#",value:"c"},{label:"Java",value:"java"},{label:"Ruby",value:"ruby"},{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"}),'//Desenvolvido pela Consultoria T\xe9cnica da Gerencianet\n\n<?php\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://api-pix-h.gerencianet.com.br/oauth/token", // Rota base, desenvolvimento 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:"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://api-pix-h.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:"js",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://api-pix-h.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:"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://api-pix-h.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:"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://api-pix-h.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:"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://api-pix-h.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:"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\n\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://api-pix.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)("br",null),Object(o.b)("h3",{id:"examples-of-authorization-responses"},"Examples of authorization responses"),Object(o.b)("p",null,"The code below represents an example of OAuth's response to your authorization request."),Object(o.b)(r.a,{defaultValue:"saida",values:[{label:"Response",value:"saida"}],mdxType:"Tabs"},Object(o.b)(c.a,{value:"saida",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": "cob.read cob.write pix.read pix.write"\n}\n')))),Object(o.b)("p",null,"The table below describes the attributes present in the JSON response."),Object(o.b)("table",null,Object(o.b)("thead",{parentName:"table"},Object(o.b)("tr",{parentName:"thead"},Object(o.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Attribute"),Object(o.b)("th",Object(a.a)({parentName:"tr"},{align:"center"}),"Description"),Object(o.b)("th",Object(a.a)({parentName:"tr"},{align:"center"}),"Type"))),Object(o.b)("tbody",{parentName:"table"},Object(o.b)("tr",{parentName:"tbody"},Object(o.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(o.b)("strong",{parentName:"td"},"access_token")),Object(o.b)("td",Object(a.a)({parentName:"tr"},{align:"center"}),"Authorization token to be used in other api requests."),Object(o.b)("td",Object(a.a)({parentName:"tr"},{align:"center"}),"string")),Object(o.b)("tr",{parentName:"tbody"},Object(o.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(o.b)("strong",{parentName:"td"},"token_type")),Object(o.b)("td",Object(a.a)({parentName:"tr"},{align:"center"}),"Authorization type in which the ",Object(o.b)("inlineCode",{parentName:"td"},"access_token")," should be used ",Object(o.b)("br",null)," ",Object(o.b)("strong",{parentName:"td"},"Padr\xe3o"),': "Bearer"'),Object(o.b)("td",Object(a.a)({parentName:"tr"},{align:"center"}),"string")),Object(o.b)("tr",{parentName:"tbody"},Object(o.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(o.b)("strong",{parentName:"td"},"expires_in")),Object(o.b)("td",Object(a.a)({parentName:"tr"},{align:"center"}),"Expiration time of the ",Object(o.b)("inlineCode",{parentName:"td"},"access_token"),", in seconds. ",Object(o.b)("br",null)," ",Object(o.b)("strong",{parentName:"td"},"Padr\xe3o:")," 3600"),Object(o.b)("td",Object(a.a)({parentName:"tr"},{align:"center"}),"Integer (int32)")),Object(o.b)("tr",{parentName:"tbody"},Object(o.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(o.b)("strong",{parentName:"td"},"scope")),Object(o.b)("td",Object(a.a)({parentName:"tr"},{align:"center"}),"List of scopes to which the authorized application has access. Scopes are separated by space."),Object(o.b)("td",Object(a.a)({parentName:"tr"},{align:"center"}),"string"))))))}d.isMDXComponent=!0},250:function(e,t,n){"use strict";n.d(t,"a",(function(){return p})),n.d(t,"b",(function(){return u}));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 s(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 l=i.a.createContext({}),b=function(e){var t=i.a.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):c(c({},t),e)),n},p=function(e){var t=b(e.components);return i.a.createElement(l.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return i.a.createElement(i.a.Fragment,{},t)}},m=i.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,o=e.originalType,r=e.parentName,l=s(e,["components","mdxType","originalType","parentName"]),p=b(n),m=a,u=p["".concat(r,".").concat(m)]||p[m]||d[m]||o;return n?i.a.createElement(u,c(c({ref:t},l),{},{components:n})):i.a.createElement(u,c({ref:t},l))}));function u(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var o=n.length,r=new Array(o);r[0]=m;var c={};for(var s in t)hasOwnProperty.call(t,s)&&(c[s]=t[s]);c.originalType=e,c.mdxType="string"==typeof e?e:a,r[1]=c;for(var l=2;l<o;l++)r[l]=n[l];return i.a.createElement.apply(null,r)}return i.a.createElement.apply(null,n)}m.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),s=n.n(c);const l=37,b=39;t.a=function(e){const{block:t,children:n,defaultValue:c,values:p,groupId:d}=e,{tabGroupChoices:m,setTabGroupChoices:u}=Object(o.a)(),[h,O]=Object(a.useState)(c);if(null!=d){const e=m[d];null!=e&&e!==h&&p.some(t=>t.value===e)&&O(e)}const g=e=>{O(e),null!=d&&u(d,e)},j=[];return i.a.createElement("div",null,i.a.createElement("ul",{role:"tablist","aria-orientation":"horizontal",className:Object(r.a)("tabs",{"tabs--block":t})},p.map(({value:e,label:t})=>i.a.createElement("li",{role:"tab",tabIndex:"0","aria-selected":h===e,className:Object(r.a)("tabs__item",s.a.tabItem,{"tabs__item--active":h===e}),key:e,ref:e=>j.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 l:((e,t)=>{const n=e.indexOf(t)-1;e[n]?e[n].focus():e[e.length-1].focus()})(e,t)}})(j,e.target,e),onFocus:()=>g(e),onClick:()=>g(e)},t))),i.a.createElement("div",{role:"tabpanel",className:"margin-vert--md"},a.Children.toArray(n).filter(e=>e.props.value===h)[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)}}}]);