1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2825],{99590:function(e,t,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/developers/app/[slug]",function(){return s(16118)}])},52229:function(e,t,s){"use strict";var r=s(67294),i=function(e,t){var s="function"==typeof Symbol&&e[Symbol.iterator];if(!s)return e;var r,i,n=s.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(r=n.next()).done;)l.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(s=n.return)&&s.call(n)}finally{if(i)throw i.error}}return l};t.Z=function(e,t){void 0===e&&(e=!1);var s=i((0,r.useState)(e),2),n=s[0],l=s[1];return[n,(0,r.useMemo)(function(){var s=void 0===t?!e:t;return{toggle:function(t){if(void 0!==t){l(t);return}l(function(t){return t===e?s:e})},setLeft:function(){return l(e)},setRight:function(){return l(s)}}},[e,t])]}},16118:function(e,t,s){"use strict";s.r(t);var r=s(85893),i=s(67294),n=s(18239),l=s(35793),c=s(11163),a=s(81758),d=s(62924),o=s(33736),h=s(20192),u=s(41664),p=s.n(u),x=s(19225),m=s(52229),j=s(29814);function f(e){let{app:t}=e,[s,n]=(0,i.useState)();return(0,r.jsxs)("div",{className:"rounded border",children:[(0,r.jsxs)("button",{className:"p-4 text-indigo-600 w-full flex items-center justify-between",onClick:()=>n(e=>!e),children:["View App Details",s?(0,r.jsx)(h.bTu,{}):(0,r.jsx)(h.Tfp,{})]}),s?(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)(j.cw,{label:"Client ID",children:(0,r.jsx)("input",{type:"text",className:"input input-bordered w-full",value:t.client_id})}),(0,r.jsx)(j.cw,{label:"Client Secret",children:(0,r.jsx)("input",{type:"text",className:"input input-bordered w-full",value:t.client_secret})}),(0,r.jsx)(j.cw,{label:"Redirect URIs",children:(0,r.jsx)("textarea",{className:"input input-bordered w-full",value:t.approved_redirect_uris})})]}):null]})}function v(e){let{id:t}=e,s=(0,c.useRouter)(),[n,l]=(0,i.useState)(!1),[a,{toggle:o}]=(0,m.Z)(!1);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{onClick:o,className:"btn bg-red-600 hover:bg-red-500 inline-flex items-center gap-2 p-2 text-white rounded",children:[(0,r.jsx)(h.Ybf,{}),"Delete app"]}),(0,r.jsx)(x.Z,{visible:a,onCancel:o,loading:n,okText:"Confirm Delete",onSubmit:()=>{l(!0),(0,d.Sv)().delete("/website/apps/".concat(t)).then(e=>{s.replace("/developers"),l(!1)})},title:"Confirm delete app",children:(0,r.jsx)("p",{children:"Are you sure you want to delete this app? This will also revoke any connected authorization tokens"})})]})}function b(e){let{client_id:t,client_secret:s,approved_redirect_uris:n}=e,[l,c]=(0,i.useState)(!1);return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"rounded border",children:[(0,r.jsxs)("button",{className:"p-4 text-indigo-600 w-full flex items-center justify-between",onClick:()=>c(e=>!e),children:["See how to set oAuth flow",l?(0,r.jsx)(h.bTu,{}):(0,r.jsx)(h.Tfp,{})]}),l?(0,r.jsx)("div",{className:"p-4",children:(0,r.jsx)(N,{client_id:t,client_secret:s,approved_redirect_uris:n})}):null]})})}function N(e){let{client_id:t,client_secret:s,approved_redirect_uris:i}=e,n=(null==i?void 0:i.split("\n")[0])||"https://goaffpro.com",l=new URL("https://goaffpro.com/oauth/authorize");l.searchParams.set("client_id",t),l.searchParams.set("scope","read_write"),l.searchParams.set("redirect_uri",n);let c=function(e){let t="",s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=s.length;for(let e=0;e<8;e++)t+=s.charAt(Math.floor(Math.random()*r));return t}(0),a=new URL(n);return a.searchParams.set("code",c),(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)("h2",{children:"How to set oAuth flow ?"}),(0,r.jsx)("h3",{className:"text-2xl mb-3",children:"Step 1"}),(0,r.jsxs)("p",{children:["Build the oAuth access URL with help of your ",(0,r.jsx)("code",{children:"client_id"}),", ",(0,r.jsx)("code",{children:"scope"})," and ",(0,r.jsx)("code",{children:"redirect_uri"})]}),(0,r.jsxs)("p",{children:["The base URL of app authorization flow is ",(0,r.jsx)("code",{children:"https://app.goaffpro.com/oauth/"})]}),(0,r.jsx)("p",{children:"Example:"}),(0,r.jsxs)("p",{className:"border border-neutral p-3 rounded",children:["https://goaffpro.com/oauth/authorize?client_id=",(0,r.jsx)("code",{children:"client_id"}),"&scope=",(0,r.jsx)("code",{children:"scope"}),"&redirect_uri=",(0,r.jsx)("code",{children:"redirect_uri"})]}),(0,r.jsx)("div",{className:"mt-4",children:"Final URL will look something like"}),(0,r.jsx)("div",{className:"form-group mb-3",children:(0,r.jsx)("input",{type:"text",className:"input input-bordered w-full",value:l.href})}),(0,r.jsx)("p",{children:"Send the user to the above URL"}),(0,r.jsx)("p",{className:"alert alert-info",children:"The app will now do the requisite steps to get the goaffpro integration set up in the merchant's store."}),(0,r.jsx)("div",{className:"divider"}),(0,r.jsx)("h3",{className:"text-2xl mb-3",children:"Step 2"}),(0,r.jsxs)("p",{children:["Once the app is setup in the merchant's store, the merchant will be redirected back to the specified ",(0,r.jsx)("code",{children:"redirect_uri"})," with an additional ",(0,r.jsx)("code",{children:"code"})," query parameter"]}),(0,r.jsx)("p",{children:"Example"}),(0,r.jsx)("p",{className:"text text-accent",children:a.href}),(0,r.jsxs)("p",{children:["You will need to extract this ",(0,r.jsx)("code",{children:"code"})," query parameter and use this to retrieve the ",(0,r.jsx)("code",{children:"access_token"})," to make API calls to the merchant's store"]}),(0,r.jsx)("p",{className:"text-xl",children:"HTTP API CALL"}),(0,r.jsxs)("div",{className:"input input-bordered w-full mb-3",children:[(0,r.jsx)("div",{className:"",children:"METHOD"}),(0,r.jsx)("div",{className:"text-lg text-info",children:"POST"})]}),(0,r.jsxs)("div",{className:"input input-bordered w-full mb-3",children:[(0,r.jsx)("div",{className:"",children:"URL"}),(0,r.jsx)("div",{className:"text-lg text-info",children:"https://api.goaffpro.com/oauth/access_token"})]}),(0,r.jsxs)("div",{className:"form-control mb-3",children:[(0,r.jsx)("div",{className:"",children:"REQUEST BODY"}),(0,r.jsx)("div",{className:"text-lg text-info",children:(0,r.jsx)("pre",{children:JSON.stringify({client_id:t,client_secret:s,grant_type:"authorization_code",code:"code",redirect_uri:n||"http://your-redirect-uri/"},null,2)})})]}),(0,r.jsx)("h4",{children:"Example"}),(0,r.jsxs)("div",{className:"bg-neutral rounded p-2 font-mono border bg-purple-100",children:[(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"text-success",children:"POST"})," https://api.goaffpro.com/oauth/access_token"]}),(0,r.jsx)("br",{}),"Content-Type: ",(0,r.jsx)("span",{style:{color:"orange"},children:"application/json"}),(0,r.jsx)("br",{}),(0,r.jsx)("br",{}),(0,r.jsx)("pre",{className:"mb-0",children:JSON.stringify({client_id:t,client_secret:s,grant_type:"authorization_code",code:"code",redirect_uri:n||"http://your-redirect-uri/"},null,2)}),(0,r.jsx)("div",{className:"divider"}),(0,r.jsx)("p",{children:"RESPONSE"}),(0,r.jsx)("pre",{className:"mb-0",children:JSON.stringify({access_token:"generated-access-token"},null,2)})]}),(0,r.jsx)("div",{className:"divider my-8"}),(0,r.jsx)("h3",{className:"text-2xl mb-3",children:"Step 3"}),(0,r.jsxs)("p",{children:["Use the retrieved ",(0,r.jsx)("code",{children:"access_token"})," to make API calls to the merchant store"]}),(0,r.jsx)("p",{children:(0,r.jsx)("a",{href:"https://api.goaffpro.com/docs/admin",className:"link",title:"Read API documentation",target:"_blank",children:"API Documentation"})})]})}t.default=function(e){let t=(0,c.useRouter)().query.slug,{data:s,isLoading:i}=(0,a.ZP)("/website/apps?id=".concat(t),d.SK),h=null==s?void 0:s.apps[0],{app_icon:u,id:x,app_name:m}=h||{};return(0,r.jsxs)("div",{children:[(0,r.jsx)(n.Z,{}),(0,r.jsxs)("div",{className:"container mx-auto",style:{maxWidth:960,marginTop:24},children:[i?(0,r.jsx)("div",{children:"Loading..."}):null,h?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex gap-2 items-center",children:[u?(0,r.jsx)("img",{src:(0,o.updateImageUrl)(u,{width:100,height:100}),alt:m,className:"w-12 h-12 rounded"}):(0,r.jsx)("div",{className:"w-12 h-12 flex items-center justify-center rounded border bg-purple-300",children:(0,r.jsx)("span",{className:"text-2xl text-white",children:m[0].toUpperCase()})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-2xl",children:m}),(0,r.jsx)("div",{children:(0,r.jsx)(p(),{href:"/developers/create?id=".concat(x),children:"Edit app"})})]})]}),(0,r.jsxs)("div",{className:"mt-4",children:[(0,r.jsx)(f,{app:h}),(0,r.jsx)("br",{}),(0,r.jsx)(b,{...h})]}),(0,r.jsx)("br",{}),(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsx)("div",{className:"flex items-end justify-end",children:(0,r.jsx)(v,{id:h.id})})})]}):null]}),(0,r.jsx)(l.Z,{})]})}}},function(e){e.O(0,[6130,3365,1664,6467,1758,2356,3258,2888,9774,179],function(){return e(e.s=99590)}),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.