-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathae633c0b.a0bc160c.js
1 lines (1 loc) · 12.6 KB
/
ae633c0b.a0bc160c.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[87],{187:function(e,a,t){"use strict";t.r(a),t.d(a,"frontMatter",(function(){return s})),t.d(a,"metadata",(function(){return l})),t.d(a,"rightToc",(function(){return u})),t.d(a,"default",(function(){return p}));var n=t(2),o=t(6),r=(t(0),t(229)),c=t(236),i=t(237),s={id:"AutenticacaoAPI",title:"Autentica\xe7\xe3o API",hide_title:!0,sidebar_label:"Autentica\xe7\xe3o API"},l={id:"AutenticacaoEndpoints/AutenticacaoAPI",isDocsHomePage:!1,title:"Autentica\xe7\xe3o API",description:"Autentica\xe7\xe3o API",source:"@site/docs\\AutenticacaoEndpoints\\AutenticacaoAPI.md",permalink:"/docs/AutenticacaoEndpoints/AutenticacaoAPI",sidebar_label:"Autentica\xe7\xe3o API",sidebar:"someSidebar",previous:{title:"Emiss\xe3o Segunda Via",permalink:"/docs/OutrosRecursos/segundavia"},next:{title:"Endpoints",permalink:"/docs/AutenticacaoEndpoints/Endpoints"}},u=[{value:"Autoriza\xe7\xe3o de acesso para aplica\xe7\xe3o",id:"autoriza\xe7\xe3o-de-acesso-para-aplica\xe7\xe3o",children:[]},{value:"Endpoint: Authorize",id:"endpoint-authorize",children:[{value:"Bibliotecas OAuth2",id:"bibliotecas-oauth2",children:[]},{value:"SDKs",id:"sdks",children:[]}]}],b={rightToc:u};function p(e){var a=e.components,t=Object(o.a)(e,["components"]);return Object(r.b)("wrapper",Object(n.a)({},b,t,{components:a,mdxType:"MDXLayout"}),Object(r.b)("h1",{className:"titulo"},"Autentica\xe7\xe3o API"),Object(r.b)("div",{className:"subtitulo"},Object(r.b)("p",null,"Este conte\xfado tem como objetivo auxiliar desenvolvedores no que tange a integra\xe7\xe3o com outras linguagens nas quais n\xe3o oferecemos ainda biblioteca, ou aqueles que desejam integrar com nossa API sem utilizar nenhuma de nossas SDKs disponibilizadas."),Object(r.b)("p",null,"A API Gerencianet responde por requisi\xe7\xf5es HTTP, indiferentemente da linguagem utilizada no ",Object(r.b)("em",{parentName:"p"},"client"),". Desta forma, caso por n\xe3o utilizar alguma de nossas SDKs, voc\xea poder\xe1 enviar os POSTs respeitando a especifica\xe7\xe3o do protocolo HTTP."),Object(r.b)("p",null,"Para sua autentica\xe7\xe3o na API, deve ser utilizado seu par de chaves Client (",Object(r.b)("code",null,"Client_Id")," e ",Object(r.b)("code",null,"Client_Secret"),") da aplica\xe7\xe3o criada em sua conta Gerencianet."),Object(r.b)("h3",{id:"autoriza\xe7\xe3o-de-acesso-para-aplica\xe7\xe3o"},"Autoriza\xe7\xe3o de acesso para aplica\xe7\xe3o"),Object(r.b)("p",null,"A API da Gerencianet \xe9 ",Object(r.b)("a",{href:"http://www.restapitutorial.com/",target:"_blank",title:"[link externo]"},"RESTful"),", as requisi\xe7\xf5es/respostas s\xe3o em JSON e utilizamos o ",Object(r.b)("a",{href:"http://oauth.net/",target:"_blank"},"OAuth")," como framework de autoriza\xe7\xe3o \xe0 API. Todas as solicita\xe7\xf5es de OAuth devem utilizar o seguinte ",Object(r.b)("em",null,"endpoint")," base:"),Object(r.b)(c.a,{defaultValue:"desenvolvimento",values:[{label:"Desenvolvimento",value:"desenvolvimento"},{label:"Produ\xe7\xe3o",value:"producao"}],mdxType:"Tabs"},Object(r.b)(i.a,{value:"desenvolvimento",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(n.a)({parentName:"pre"},{className:"language-json"}),'"URL": {\n "sandbox": "https://sandbox.gerencianet.com.br/v1/"\n },\n'))),Object(r.b)(i.a,{value:"producao",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(n.a)({parentName:"pre"},{className:"language-json"}),'"URL": {\n "production": "https://api.gerencianet.com.br/v1/"\n },\n')))),Object(r.b)("br",null),Object(r.b)("h2",{id:"endpoint-authorize"},"Endpoint: Authorize"),Object(r.b)("p",null,"A API da Gerencianet \xe9 compat\xedvel com o protocolo ",Object(r.b)("a",{href:"http://oauth.net/2/",target:"_blank"},"OAuth 2.0")," para autorizar acesso \xe0 API. As requisi\xe7\xf5es s\xe3o autenticadas usando ",Object(r.b)("a",{href:"https://en.wikipedia.org/wiki/Basic_access_authentication",target:"_blank",title:"Link Externo"},"HTTP Basic Auth"),"."),Object(r.b)("p",null,"O objetivo do protocolo OAuth2 \xe9 a troca de uma cadeia de tokens entre o ",Object(r.b)("em",{parentName:"p"},"Cliente")," e ",Object(r.b)("em",{parentName:"p"},"Server Resource"),". Esse token \xe9 usado para autenticar todas as chamadas a API usando ",Object(r.b)("em",{parentName:"p"},"Authorization")," no cabe\xe7alho do HTTP."),Object(r.b)("p",null,"O ",Object(r.b)("em",{parentName:"p"},"endpoint")," base \xe9:"),Object(r.b)(c.a,{defaultValue:"authorize",values:[{label:"Endpoint: Authorize",value:"authorize"}],mdxType:"Tabs"},Object(r.b)(i.a,{value:"authorize",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(n.a)({parentName:"pre"},{className:"language-json"}),'"authorize": {\n "route": "/v1/authorize",\n "method": "post"\n}\n')))),Object(r.b)("br",null),Object(r.b)("h3",{id:"bibliotecas-oauth2"},"Bibliotecas OAuth2"),Object(r.b)("p",null,"H\xe1 bibliotecas OAuth2 para in\xfameras linguagens. Se por alguma raz\xe3o decida n\xe3o utilizar nenhuma de nossas SDKs disponibilizadas, ser\xe1 necess\xe1rio que voc\xea fa\xe7a este processo de autentica\xe7\xe3o. ",Object(r.b)("a",{href:"https://oauth.net/code/",target:"_blank",title:"Link Externo"},"Escolha uma biblioteca antes de come\xe7ar"),"."),Object(r.b)("h3",{id:"sdks"},"SDKs"),Object(r.b)("p",null,"Caso opte por utilizar nossa SDK, todas as bibliotecas disponibilizadas aqui j\xe1 est\xe3o preparadas para realizar a autentica\xe7\xe3o com OAuth automaticamente. Clique na aba referente \xe0 linguagem de sua prefer\xeancia para baixar a biblioteca."),Object(r.b)(c.a,{defaultValue:"php",values:[{label:"PHP",value:"php"},{label:"Python",value:"python"},{label:"NodeJS",value:"js"},{label:".NET",value:"c"},{label:"Java",value:"java"},{label:"GO",value:"go"},{label:"Ruby",value:"ruby"},{label:"Delphi",value:"delphi"}],mdxType:"Tabs"},Object(r.b)(i.a,{value:"php",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(n.a)({parentName:"pre"},{className:"language-php"}),"// Instalando via Packagist com o Composer:\n// Packagist: https://packagist.org/packages/gerencianet/gerencianet-sdk-php\n// Composer: https://getcomposer.org/\n\n$ composer require gerencianet/gerencianet-sdk-php\n\n// Ou, se preferir, confira a documenta\xe7\xe3o completa sobre como instalar a SDK \n"))),Object(r.b)(i.a,{value:"python",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(n.a)({parentName:"pre"},{className:"language-php"}),"// Instalando via Pip (https://pypi.python.org/pypi/pip):\n\n$ pip install gerencianet\n\n// Ou, se preferir, confira a documenta\xe7\xe3o completa sobre como instalar a SDK\n"))),Object(r.b)(i.a,{value:"js",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(n.a)({parentName:"pre"},{className:"language-js"}),"// Instalando via NPM (https://www.npmjs.com/package/gn-api-sdk-node):\n\n$ npm install gn-api-sdk-node\n\n// Ou, se preferir, confira a documenta\xe7\xe3o completa sobre como instalar a SDK\n"))),Object(r.b)(i.a,{value:"c",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(n.a)({parentName:"pre"},{className:"language-js"}),"// Instalando via NuGet (https://www.nuget.org/):\n\n$ nuget install Gerencianet.SDK\n \n// Ou, se preferir, confira a documenta\xe7\xe3o completa sobre como instalar a SDK\n"))),Object(r.b)(i.a,{value:"java",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(n.a)({parentName:"pre"},{className:"language-java"}),"// Instalando via gradle:\ncompile 'br.com.gerencianet.gnsdk:gn-api-sdk-java:0.1.0'\n\n// Instalando via maven:\n<dependency>\n <groupId>br.com.gerencianet.gnsdk</groupId>\n <artifactId>gn-api-sdk-java</artifactId>\n <version>0.1.0</version>\n</dependency>\n// O Maven automaticamente instalar\xe1 a SDK e todas as suas depend\xeancias.\n\n// Ou, se preferir, confira a documenta\xe7\xe3o completa sobre como instalar a SDK\n"))),Object(r.b)(i.a,{value:"go",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(n.a)({parentName:"pre"},{className:"language-go"}),"$ go get github.com/gerencianet/gn-api-sdk-go/gerencianet\n\n// Ou, se preferir, confira a documenta\xe7\xe3o completa:\n"))),Object(r.b)(i.a,{value:"ruby",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(n.a)({parentName:"pre"},{className:"language-js"}),"// Instalando via RubyGems (https://rubygems.org/gems/gerencianet):\n\n$ gem install gerencianet\n\n// Ou, se preferir, confira a documenta\xe7\xe3o completa sobre como instalar a SDK\n"))),Object(r.b)(i.a,{value:"delphi",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(n.a)({parentName:"pre"},{className:"language-json"}),"// Confira a documenta\xe7\xe3o completa sobre como instalar a SDK\n"))))))}p.isMDXComponent=!0},229:function(e,a,t){"use strict";t.d(a,"a",(function(){return b})),t.d(a,"b",(function(){return m}));var n=t(0),o=t.n(n);function r(e,a,t){return a in e?Object.defineProperty(e,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[a]=t,e}function c(e,a){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);a&&(n=n.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),t.push.apply(t,n)}return t}function i(e){for(var a=1;a<arguments.length;a++){var t=null!=arguments[a]?arguments[a]:{};a%2?c(Object(t),!0).forEach((function(a){r(e,a,t[a])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):c(Object(t)).forEach((function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(t,a))}))}return e}function s(e,a){if(null==e)return{};var t,n,o=function(e,a){if(null==e)return{};var t,n,o={},r=Object.keys(e);for(n=0;n<r.length;n++)t=r[n],a.indexOf(t)>=0||(o[t]=e[t]);return o}(e,a);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;n<r.length;n++)t=r[n],a.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var l=o.a.createContext({}),u=function(e){var a=o.a.useContext(l),t=a;return e&&(t="function"==typeof e?e(a):i(i({},a),e)),t},b=function(e){var a=u(e.components);return o.a.createElement(l.Provider,{value:a},e.children)},p={inlineCode:"code",wrapper:function(e){var a=e.children;return o.a.createElement(o.a.Fragment,{},a)}},d=o.a.forwardRef((function(e,a){var t=e.components,n=e.mdxType,r=e.originalType,c=e.parentName,l=s(e,["components","mdxType","originalType","parentName"]),b=u(t),d=n,m=b["".concat(c,".").concat(d)]||b[d]||p[d]||r;return t?o.a.createElement(m,i(i({ref:a},l),{},{components:t})):o.a.createElement(m,i({ref:a},l))}));function m(e,a){var t=arguments,n=a&&a.mdxType;if("string"==typeof e||n){var r=t.length,c=new Array(r);c[0]=d;var i={};for(var s in a)hasOwnProperty.call(a,s)&&(i[s]=a[s]);i.originalType=e,i.mdxType="string"==typeof e?e:n,c[1]=i;for(var l=2;l<r;l++)c[l]=t[l];return o.a.createElement.apply(null,c)}return o.a.createElement.apply(null,t)}d.displayName="MDXCreateElement"},233:function(e,a,t){"use strict";function n(e){var a,t,o="";if("string"==typeof e||"number"==typeof e)o+=e;else if("object"==typeof e)if(Array.isArray(e))for(a=0;a<e.length;a++)e[a]&&(t=n(e[a]))&&(o&&(o+=" "),o+=t);else for(a in e)e[a]&&(o&&(o+=" "),o+=a);return o}a.a=function(){for(var e,a,t=0,o="";t<arguments.length;)(e=arguments[t++])&&(a=n(e))&&(o&&(o+=" "),o+=a);return o}},234:function(e,a,t){"use strict";var n=t(0);const o=Object(n.createContext)({tabGroupChoices:{},setTabGroupChoices:()=>{},isAnnouncementBarClosed:!1,closeAnnouncementBar:()=>{}});a.a=o},235:function(e,a,t){"use strict";var n=t(0),o=t(234);a.a=function(){return Object(n.useContext)(o.a)}},236:function(e,a,t){"use strict";var n=t(0),o=t.n(n),r=t(235),c=t(233),i=t(92),s=t.n(i);const l=37,u=39;a.a=function(e){const{block:a,children:t,defaultValue:i,values:b,groupId:p}=e,{tabGroupChoices:d,setTabGroupChoices:m}=Object(r.a)(),[O,j]=Object(n.useState)(i);if(null!=p){const e=d[p];null!=e&&e!==O&&b.some(a=>a.value===e)&&j(e)}const g=e=>{j(e),null!=p&&m(p,e)},f=[];return o.a.createElement("div",null,o.a.createElement("ul",{role:"tablist","aria-orientation":"horizontal",className:Object(c.a)("tabs",{"tabs--block":a})},b.map(({value:e,label:a})=>o.a.createElement("li",{role:"tab",tabIndex:"0","aria-selected":O===e,className:Object(c.a)("tabs__item",s.a.tabItem,{"tabs__item--active":O===e}),key:e,ref:e=>f.push(e),onKeyDown:e=>((e,a,t)=>{switch(t.keyCode){case u:((e,a)=>{const t=e.indexOf(a)+1;e[t]?e[t].focus():e[0].focus()})(e,a);break;case l:((e,a)=>{const t=e.indexOf(a)-1;e[t]?e[t].focus():e[e.length-1].focus()})(e,a)}})(f,e.target,e),onFocus:()=>g(e),onClick:()=>g(e)},a))),o.a.createElement("div",{role:"tabpanel",className:"margin-vert--md"},n.Children.toArray(t).filter(e=>e.props.value===O)[0]))}},237:function(e,a,t){"use strict";var n=t(0),o=t.n(n);a.a=function(e){return o.a.createElement("div",null,e.children)}}}]);