{"_id":"@arepp23/intuit-oauth","name":"@arepp23/intuit-oauth","dist-tags":{"latest":"4.0.0"},"versions":{"4.0.0":{"name":"@arepp23/intuit-oauth","version":"4.0.0","description":"Intuit Node.js client for OAuth2.0 and OpenIDConnect","main":"./src/OAuthClient.js","scripts":{"start":"node index.js","karma":"karma start karma.conf.js","test":"nyc mocha","snyk":"snyk test","lint":"eslint .","fix":"eslint . --fix","posttest":"nyc check-coverage","test-watch":"mocha --watch --reporter=spec","test-debug":"mocha --inspect-brk --watch test","show-coverage":"npm test; open -a 'Google Chrome' coverage/index.html","clean-install":"rm -rf node_modules && npm install","snyk-protect":"snyk protect","prepublish":"npm run snyk-protect"},"keywords":["intuit-oauth","intuit-oauth-nodejs","intuit-nodejs","oauth2.0","openid","openidConnect","quickbooks-accounting","quickbooks-payment"],"nyc":{"exclude":["node_modules","bin","coverage",".nyc_output","sample","sample/node_modules"],"check-coverage":true,"lines":95,"statements":95,"functions":90,"branches":85,"reporter":["lcov","text","text-summary","html","json"]},"engines":{"node":">=10"},"repository":{"type":"git","url":"git+https://github.com/intuit/oauth-jsclient.git"},"author":{"name":"Anil Kumar","email":"anil_kumar3@intuit.com"},"license":"Apache-2.0","bugs":{"url":"https://github.com/intuit/oauth-jsclient/issues"},"homepage":"https://github.com/intuit/oauth-jsclient","dependencies":{"atob":"2.1.2","axios":"^1.5.1","csrf":"^3.0.4","jsonwebtoken":"^9.0.2","query-string":"^6.12.1","rsa-pem-from-mod-exp":"^0.8.4","winston":"^3.1.0"},"devDependencies":{"btoa":"^1.2.1","chai":"^4.1.2","chai-as-promised":"^7.1.1","eslint":"^6.8.0","eslint-config-airbnb-base":"^14.1.0","eslint-config-prettier":"^6.11.0","eslint-plugin-import":"^2.20.2","mocha":"^10.2.0","nock":"^9.2.3","nyc":"^15.0.1","prettier":"^2.0.5","sinon":"^9.0.2","snyk":"^1.316.1"},"snyk":true,"directories":{"test":"test"},"gitHead":"1e7115078590a1e1361444d45720de899e9720b1","_id":"@arepp23/intuit-oauth@4.0.0","_nodeVersion":"18.12.0","_npmVersion":"8.3.0","dist":{"integrity":"sha512-1CutRdV0nW1sGiZe2RhGZ3opyXiA2+NwZFR7g/yBbxXBLPJZnkgDpGvFS5dZhIcwOPoGon72nVegcDGPB+qCEA==","shasum":"b28b0e9691c1c04c7ebbb3b17fc40b4fe8703005","tarball":"https://registry.npmjs.org/@arepp23/intuit-oauth/-/intuit-oauth-4.0.0.tgz","fileCount":46,"unpackedSize":712931,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHPgkTL11daM/rRgXKYk+GJGcbn6tG89HAh0ZGIc2DwJAiAPEXpTmEqmIRTXXxJS1Zqr3cj9Lxjgx+00Xjy9MjWqXw=="}]},"_npmUser":{"name":"arepp23","email":"austinmrepp@gmail.com"},"maintainers":[{"name":"arepp23","email":"austinmrepp@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/intuit-oauth_4.0.0_1709008604076_0.41915747970857464"},"_hasShrinkwrap":false}},"time":{"created":"2024-02-27T04:36:43.970Z","4.0.0":"2024-02-27T04:36:44.237Z","modified":"2024-02-27T04:36:45.233Z"},"maintainers":[{"name":"arepp23","email":"austinmrepp@gmail.com"}],"description":"Intuit Node.js client for OAuth2.0 and OpenIDConnect","homepage":"https://github.com/intuit/oauth-jsclient","keywords":["intuit-oauth","intuit-oauth-nodejs","intuit-nodejs","oauth2.0","openid","openidConnect","quickbooks-accounting","quickbooks-payment"],"repository":{"type":"git","url":"git+https://github.com/intuit/oauth-jsclient.git"},"author":{"name":"Anil Kumar","email":"anil_kumar3@intuit.com"},"bugs":{"url":"https://github.com/intuit/oauth-jsclient/issues"},"license":"Apache-2.0","readme":"[![SDK Banner](views/SDK.png)][ss1]\r\n\r\n[![Build Status](https://travis-ci.org/intuit/oauth-jsclient.svg?branch=master)](https://travis-ci.org/intuit/oauth-jsclient?branch=master)\r\n[![NPM Package Version](https://img.shields.io/npm/v/intuit-oauth.svg?style=flat-square)](https://www.npmjs.com/package/intuit-oauth)\r\n[![Coverage Status](https://coveralls.io/repos/github/intuit/oauth-jsclient/badge.svg?branch=master)](https://coveralls.io/github/intuit/oauth-jsclient?branch=master)\r\n[![GitHub contributors](https://img.shields.io/github/contributors/intuit/oauth-jsclient?style=flat-square)](https://github.com/intuit/oauth-jsclient/graphs/contributors)\r\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/intuit/oauth-jsclient/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/intuit/oauth-jsclient/?branch=master)\r\n![npm](https://img.shields.io/npm/dm/intuit-oauth?style=flat-square)\r\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=shield)](https://github.com/prettier/prettier)\r\n[![Known Vulnerabilities](https://snyk.io/test/github/intuit/oauth-jsclient/badge.svg)](https://snyk.io/test/github/intuit/oauth-jsclient)\r\n\r\n# Intuit OAuth2.0 NodeJS Library\r\n\r\nThe OAuth2 Nodejs Client library is meant to work with Intuit's\r\n[OAuth2.0](https://developer.intuit.com/app/developer/qbo/docs/develop/authentication-and-authorization/oauth-2.0)\r\nand\r\n[OpenID Connect](https://developer.intuit.com/app/developer/qbo/docs/develop/authentication-and-authorization/openid-connect)\r\nimplementations which conforms to the specifications.\r\n\r\n## Table of Contents\r\n\r\n- [Intuit OAuth2.0 NodeJS Library](#intuit-oauth20-nodejs-library)\r\n  - [Table of Contents](#table-of-contents)\r\n- [Requirements](#requirements)\r\n- [Installation](#installation)\r\n  - [Using NodeJS](#using-nodejs)\r\n    - [Options :](#options)\r\n- [Usage](#usage)\r\n  - [Authorization Code Flow](#authorization-code-flow)\r\n    - [Step 1](#step-1)\r\n    - [Scopes :](#scopes)\r\n    - [Step 2](#step-2)\r\n- [Sample](#sample)\r\n  - [Helpers](#helpers)\r\n    - [Is AccessToken Valid](#is-accesstoken-valid)\r\n    - [Refresh access_token](#refresh-access_token)\r\n    - [Refresh access_token by passing the refresh_token explicitly](#refresh-access_token-by-passing-the-refresh_token-explicitly)\r\n    - [Revoke access_token](#retrieve-the-token-)\r\n    - [Getter / Setter for Token](#getter--setter-for-token)\r\n      - [Retrieve the Token :](#retrieve-the-token)\r\n      - [Set the Token :](#set-the-token-)\r\n    - [Migrate OAuth1.0 Tokens to OAuth2.0](#migrate-oauth10-tokens-to-oauth20)\r\n    - [Validate ID Token](#validate-id-token)\r\n    - [Make API call](#make-api-call)\r\n    - [Auth-Response](#auth-response)\r\n    - [Error Logging](#error-logging)\r\n  - [FAQ](#faq)\r\n  - [Contributing](#contributing)\r\n    - [Steps](#steps)\r\n  - [Changelog](#changelog)\r\n  - [License](#license)\r\n\r\n# Requirements\r\n\r\nThe Node.js client library is tested against the `Node 10` and newer versions.\r\n\r\n| Version                                                                          | Node support                      |\r\n|----------------------------------------------------------------------------------|-----------------------------------|\r\n| [intuit-oauth@1.x.x](https://github.com/intuit/oauth-jsclient/tree/1.5.0)        | Node 6.x or higher                |\r\n| [intuit-oauth@2.x.x](https://github.com/intuit/oauth-jsclient/tree/2.0.0)        | Node 7.x or higher                |\r\n| [intuit-oauth@3.x.x](https://github.com/intuit/oauth-jsclient/tree/3.0.2)        | Node 8.x or Node 9.x and higher   |\r\n\r\n**Note**: Older node versions are not supported.\r\n\r\n# Installation\r\n\r\nFollow the instructions below to use the library :\r\n\r\n## Using NodeJS\r\n\r\n1. Install the NPM package:\r\n\r\n   ```sh\r\n   npm install intuit-oauth --save\r\n   ```\r\n\r\n2. Require the Library:\r\n\r\n   ```js\r\n   const OAuthClient = require('intuit-oauth');\r\n\r\n   const oauthClient = new OAuthClient({\r\n     clientId: '<Enter your clientId>',\r\n     clientSecret: '<Enter your clientSecret>',\r\n     environment: 'sandbox' || 'production',\r\n     redirectUri: '<Enter your callback URL>',\r\n   });\r\n   ```\r\n\r\n### Options\r\n\r\n- `clientId` - clientID for your app. Required\r\n- `clientSecret` - clientSecret fpor your app. Required\r\n- `environment` - environment for the client. Required\r\n  - `sandbox` - for authorizing in sandbox.\r\n  - `production` - for authorizing in production.\r\n- `redirectUri` - redirectUri on your app to get the `authorizationCode` from Intuit Servers. Make sure this redirect URI is also added on your app in the [developer portal](https://developer.intuit.com) on the Keys & OAuth tab. Required\r\n- `logging` - by default, logging is disabled i.e `false`. To enable provide`true`.\r\n\r\n# Usage\r\n\r\nWe assume that you have a basic understanding about OAuth2.0. If not please read\r\n[API Documentation](https://developer.intuit.com/app/developer/qbo/docs/develop/authentication-and-authorization/oauth-2.0)\r\nfor clear understanding\r\n\r\n## Authorization Code Flow\r\n\r\nThe Authorization Code flow is made up of two parts :\r\n\r\n**Step 1.** Redirect user to `oauthClient.authorizeUri(options)`.  \r\n**Step 2.** Parse response uri and get access-token using the function\r\n`oauthClient.createToken(req.url)` which returns a\r\n[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).\r\n\r\n### Step 1\r\n\r\n```javascript\r\n// Instance of client\r\nconst oauthClient = new OAuthClient({\r\n  clientId: '<Enter your clientId>',\r\n  clientSecret: '<Enter your clientSecret>',\r\n  environment: 'sandbox',\r\n  redirectUri: '<http://localhost:8000/callback>',\r\n});\r\n\r\n// AuthorizationUri\r\nconst authUri = oauthClient.authorizeUri({\r\n  scope: [OAuthClient.scopes.Accounting, OAuthClient.scopes.OpenId],\r\n  state: 'testState',\r\n}); // can be an array of multiple scopes ex : {scope:[OAuthClient.scopes.Accounting,OAuthClient.scopes.OpenId]}\r\n\r\n// Redirect the authUri\r\nres.redirect(authUri);\r\n```\r\n\r\n### Scopes\r\n\r\nThe available scopes include :\r\n\r\n- `com.intuit.quickbooks.accounting` - for accounting scope include `OAuthClient.scopes.Accounting`\r\n- `com.intuit.quickbooks.payment` - for payment scope include `OAuthClient.scopes.Payment`\r\n- `com.intuit.quickbooks.payroll` - for QuickBooks Payroll API (whitelisted beta apps only)\r\n- `com.intuit.quickbooks.payroll.timetracking` - for QuickBooks Payroll API for for access to\r\n  compensation (whitelisted beta apps only)\r\n- `com.intuit.quickbooks.payroll.benefits` - for QuickBooks Payroll API for access to\r\n  benefits/pension/deduction (whitelisted beta apps only)\r\n\r\nOpenID Scopes :\r\n\r\n- `openid` - for openID assertion include `OAuthClient.scopes.OpenId`\r\n- `profile` - for profile assertion include `OAuthClient.scopes.Profile`\r\n- `email` - for email assertion include `OAuthClient.scopes.Email`\r\n- `phone` - for phone assertion include `OAuthClient.scopes.Phone`\r\n- `address` - for address assertion include `OAuthClient.scopes.Address`\r\n\r\n### Step 2\r\n\r\n```javascript\r\n// Parse the redirect URL for authCode and exchange them for tokens\r\nconst parseRedirect = req.url;\r\n\r\n// Exchange the auth code retrieved from the **req.url** on the redirectUri\r\noauthClient\r\n  .createToken(parseRedirect)\r\n  .then(function (authResponse) {\r\n    console.log('The Token is  ' + JSON.stringify(authResponse.getJson()));\r\n  })\r\n  .catch(function (e) {\r\n    console.error('The error message is :' + e.originalMessage);\r\n    console.error(e.intuit_tid);\r\n  });\r\n```\r\n\r\n# Sample\r\n\r\nFor more clarity, we suggest you take a look at the sample application below :  \r\n[sample](https://github.com/intuit/oauth-jsclient/tree/master/sample)\r\n\r\n## Helpers\r\n\r\n### Is AccessToken Valid\r\n\r\nYou can check if the `access_token` associated with the `oauthClient` is valid ( not expired ) or\r\nnot using the helper method.\r\n\r\n```javascript\r\nif (oauthClient.isAccessTokenValid()) {\r\n  console.log('The access_token is valid');\r\n}\r\n\r\nif (!oauthClient.isAccessTokenValid()) {\r\n  oauthClient\r\n    .refresh()\r\n    .then(function (authResponse) {\r\n      console.log('Tokens refreshed : ' + JSON.stringify(authResponse.json()));\r\n    })\r\n    .catch(function (e) {\r\n      console.error('The error message is :' + e.originalMessage);\r\n      console.error(e.intuit_tid);\r\n    });\r\n}\r\n```\r\n\r\n\\*\\* Note: If the access_token is not valid, you can call the client's `refresh()` method to refresh\r\nthe tokens for you as shown below\r\n\r\n### Refresh access_token\r\n\r\nAccess tokens are valid for 3600 seconds (one hour), after which time you need to get a fresh one\r\nusing the latest refresh_token returned to you from the previous request. When you request a fresh\r\naccess_token, always use the refresh token returned in the most recent token_endpoint response. Your\r\nprevious refresh tokens expire 24 hours after you receive a new one.\r\n\r\n```javascript\r\noauthClient\r\n  .refresh()\r\n  .then(function (authResponse) {\r\n    console.log('Tokens refreshed : ' + JSON.stringify(authResponse.getJson()));\r\n  })\r\n  .catch(function (e) {\r\n    console.error('The error message is :' + e.originalMessage);\r\n    console.error(e.intuit_tid);\r\n  });\r\n```\r\n\r\n### Refresh access_token by passing the refresh_token explicitly\r\n\r\nYou can call the below helper method to refresh tokens by explictly passing the refresh_token.  \r\n\\*\\*Note : `refresh_token` should be of the type `string`\r\n\r\n```javascript\r\noauthClient\r\n  .refreshUsingToken('<Enter the refresh token>')\r\n  .then(function (authResponse) {\r\n    console.log('Tokens refreshed : ' + JSON.stringify(authResponse.getJson()));\r\n  })\r\n  .catch(function (e) {\r\n    console.error('The error message is :' + e.originalMessage);\r\n    console.error(e.intuit_tid);\r\n  });\r\n```\r\n\r\n### Revoke access_token\r\n\r\nWhen you no longer need the access_token, you could use the below helper method to revoke the\r\ntokens.\r\n\r\n```javascript\r\noauthClient\r\n  .revoke()\r\n  .then(function (authResponse) {\r\n    console.log('Tokens revoked : ' + JSON.stringify(authResponse.getJson()));\r\n  })\r\n  .catch(function (e) {\r\n    console.error('The error message is :' + e.originalMessage);\r\n    console.error(e.intuit_tid);\r\n  });\r\n```\r\n\r\nAlternatively you can also pass `access_token` or `refresh_token` to this helper method using the\r\n`params` object: refer to - [Getter / Setter for Token](#getter--setter-for-token) section to know\r\nhow to retrieve the `token` object\r\n\r\n```javascript\r\noauthClient\r\n  .revoke(params)\r\n  .then(function (authResponse) {\r\n    console.log('Tokens revoked : ' + JSON.stringify(authResponse.getJson()));\r\n  })\r\n  .catch(function (e) {\r\n    console.error('The error message is :' + e.originalMessage);\r\n    console.error(e.intuit_tid);\r\n  });\r\n```\r\n\r\n** Note ** : `params` is the Token JSON object as shown below : ( _If you do not pass the `params`\r\nthen the token object of the client would be considered._)\r\n\r\n```\r\n{\r\n    \"token_type\": \"bearer\",\r\n    \"expires_in\": 3600,\r\n    \"refresh_token\":\"<refresh_token>\",\r\n    \"x_refresh_token_expires_in\":15552000,\r\n    \"access_token\":\"<access_token>\",\r\n    \"createdAt\": \"(Optional Default = Date.now()) <Milliseconds> from the unix epoch\"\r\n\r\n}\r\n```\r\n\r\n** Note ** :\r\n\r\n### Getter / Setter for Token\r\n\r\nYou can call the below methods to set and get the tokens using the `oauthClient` instance:\r\n\r\n#### Retrieve the Token :\r\n\r\n```javascript\r\n// To get the tokens\r\nlet authToken = oauthClient.getToken().getToken();\r\n\r\n`OR`;\r\n\r\nlet authToken = oauthClient.token.getToken();\r\n```\r\n\r\n#### Set the Token :\r\n\r\n```javascript\r\n// To Set the retrieved tokens explicitly using Token Object but the same instance\r\noauthClient.setToken(authToken);\r\n\r\nOR;\r\n\r\n// To set the retrieved tokens using a new client instance\r\nconst oauthClient = new OAuthClient({\r\n  clientId: '<Enter your clientId>',\r\n  clientSecret: '<Enter your clientSecret>',\r\n  environment: 'sandbox',\r\n  redirectUri: '<http://localhost:8000/callback>',\r\n  token: authToken,\r\n});\r\n```\r\n\r\nThe authToken parameters are as follows:\r\n\r\n```\r\n{\r\n    token_type: '<String>',\r\n    access_token: '<String>',\r\n    expires_in: '<Int> Seconds',\r\n    refresh_token: '<String>',\r\n    x_refresh_token_expires_in: '<Int>  Seconds',\r\n    id_token: \"(Optional Default = '') <String>\",\r\n    createdAt: '(Optional Default = Date.now()) <Milliseconds> from the unix epoch'\r\n}\r\n```\r\n\r\n**Note** :  \r\nThe OAuth Client library converts the accessToken and refreshToken expiry time to `TimeStamp`. If\r\nyou are setting a stored token, please pass in the `createdAt` for accurate experiations.\r\n\r\n```javascript\r\noauthClient.setToken(authToken);\r\n```\r\n\r\n### Migrate OAuth1.0 Tokens to OAuth2.0\r\n\r\nYou can call the below method to migrate the bearer / refresh tokens from OAuth1.0 to OAuth2.0. You\r\n\r\n```javascript\r\n// Fill in the params object ( argument to the migrate function )\r\n\r\nlet params = {\r\n  oauth_consumer_key: '<Enter oauth1ConsumerKey>',\r\n  oauth_consumer_secret: '<Enter oauth1ConsumerSecret>',\r\n  oauth_signature_method: 'HMAC-SHA1',\r\n  oauth_timestamp: Math.round(new Date().getTime() / 1000),\r\n  oauth_nonce: 'nonce',\r\n  oauth_version: '1.0',\r\n  access_token: '<Enter OAuth1.0 access_token>',\r\n  access_secret: '<Enter OAuth1.0 access_secret>',\r\n  scope: [OAuthClient.scopes.Accounting],\r\n};\r\n\r\noauthClient\r\n  .migrate(params)\r\n  .then(function (response) {\r\n    console.log('The response is ' + JSON.stringify(response));\r\n  })\r\n  .catch(function (e) {\r\n    console.log('The error is ' + e.message);\r\n  });\r\n```\r\n\r\n### Validate ID Token\r\n\r\nYou can validate the ID token obtained from `Intuit Authorization Server` as shown below :\r\n\r\n```javascript\r\noauthClient\r\n  .validateIdToken()\r\n  .then(function (response) {\r\n    console.log('Is my ID token validated  : ' + response);\r\n  })\r\n  .catch(function (e) {\r\n    console.log('The error is ' + JSON.stringify(e));\r\n  });\r\n\r\n// Is my ID token validated : true\r\n```\r\n\r\nThe client validates the ID Token and returns boolean `true` if validates successfully else it would\r\nthrow an exception.\r\n\r\n### Make API Call\r\n\r\nYou can make API call using the token generated from the client as shown below :\r\n\r\n```javascript\r\n// Body sample from API explorer examples\r\nconst body = {\r\n  TrackQtyOnHand: true,\r\n  Name: 'Garden Supplies',\r\n  QtyOnHand: 10,\r\n  InvStartDate: '2015-01-01',\r\n  Type: 'Inventory',\r\n  IncomeAccountRef: {\r\n    name: 'Sales of Product Income',\r\n    value: '79',\r\n  },\r\n  AssetAccountRef: {\r\n    name: 'Inventory Asset',\r\n    value: '81',\r\n  },\r\n  ExpenseAccountRef: {\r\n    name: 'Cost of Goods Sold',\r\n    value: '80',\r\n  },\r\n};\r\n\r\noauthClient\r\n  .makeApiCall({\r\n    url: 'https://sandbox-quickbooks.api.intuit.com/v3/company/1234/item',\r\n    method: 'POST',\r\n    headers: {\r\n      'Content-Type': 'application/json',\r\n    },\r\n    body: JSON.stringify(body),\r\n  })\r\n  .then(function (response) {\r\n    console.log('The API response is  : ' + response);\r\n  })\r\n  .catch(function (e) {\r\n    console.log('The error is ' + JSON.stringify(e));\r\n  });\r\n```\r\n\r\nThe client validates the ID Token and returns boolean `true` if validates successfully else it would\r\nthrow an exception.\r\n\r\n#### Support for PDF format\r\nIn order to save the PDF generated from the APIs properly, the correct transport type should be passed into the `makeAPI()`.Below is an example of the same:\r\n```\r\n.makeApiCall({ url: `${url}v3/company/${companyID}/invoice/${invoiceNumber}/pdf?minorversion=59` , headers:{'Content-Type': 'application/pdf','Accept':'application/pdf'}, transport: popsicle.createTransport({type: 'buffer'})})\r\n```\r\nThe response is an actual buffer( binary BLOB) which could then be saved to the file. \r\n\r\n### Auth-Response\r\n\r\nThe response provided by the client is a wrapped response of the below items which is what we call\r\nauthResponse, lets see how it looks like:\r\n\r\n```text\r\n\r\n    1. response             // response from `HTTP Client` used by library\r\n    2. token                // instance of `Token` Object\r\n    3. body                 // res.body in `text`\r\n    4. json                 // res.body in `JSON`\r\n    5. intuit_tid           // `intuit-tid` from response headers\r\n\r\n```\r\n\r\nA sample `AuthResponse` object would look similar to :\r\n\r\n```json\r\n{\r\n  \"token\": {\r\n    \"realmId\": \"<realmId>\",\r\n    \"token_type\": \"bearer\",\r\n    \"access_token\": \"<access_token>\",\r\n    \"refresh_token\": \"<refresh_token>\",\r\n    \"expires_in\": 3600,\r\n    \"x_refresh_token_expires_in\": 8726400,\r\n    \"id_token\": \"<id_token>\",\r\n    \"latency\": 60000\r\n  },\r\n  \"response\": {\r\n    \"url\": \"https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer\",\r\n    \"headers\": {\r\n      \"content-type\": \"application/json;charset=UTF-8\",\r\n      \"content-length\": \"61\",\r\n      \"connection\": \"close\",\r\n      \"server\": \"nginx\",\r\n      \"strict-transport-security\": \"max-age=15552000\",\r\n      \"intuit_tid\": \"1234-1234-1234-123\",\r\n      \"cache-control\": \"no-cache, no-store\",\r\n      \"pragma\": \"no-cache\"\r\n    },\r\n    \"body\": \"{\\\"id_token\\\":\\\"<id_token>\\\",\\\"expires_in\\\":3600,\\\"token_type\\\":\\\"bearer\\\",\\\"x_refresh_token_expires_in\\\":8726400,\\\"refresh_token\\\":\\\"<refresh_token>\\\",\\\"access_token\\\":\\\"<access_token>\\\"}\",\r\n    \"status\": 200,\r\n    \"statusText\": \"OK\"\r\n  },\r\n  \"body\": \"{\\\"id_token\\\":\\\"<id_token>\\\",\\\"expires_in\\\":3600,\\\"token_type\\\":\\\"bearer\\\",\\\"x_refresh_token_expires_in\\\":8726400,\\\"refresh_token\\\":\\\"<refresh_token>\\\",\\\"access_token\\\":\\\"<access_token>\\\"}\",\r\n  \"json\": {\r\n    \"access_token\": \"<access_token>\",\r\n    \"refresh_token\": \"<refresh_token>\",\r\n    \"token_type\": \"bearer\",\r\n    \"expires_in\": \"3600\",\r\n    \"x_refresh_token_expires_in\": \"8726400\",\r\n    \"id_token\": \"<id_token>\"\r\n  },\r\n  \"intuit_tid\": \"4245c696-3710-1548-d1e0-d85918e22ebe\"\r\n}\r\n```\r\n\r\nYou can use the below helper methods to make full use of the Auth Response Object :\r\n\r\n```javascript\r\noauthClient.createToken(parseRedirect).then(function (authResponse) {\r\n  console.log('The Token in JSON is  ' + JSON.stringify(authResponse.getJson()));\r\n  let status = authResponse.status();\r\n  let body = authResponse.text();\r\n  let jsonResponse = authResponse.getJson();\r\n  let intuit_tid = authResponse.get_intuit_tid();\r\n});\r\n```\r\n\r\n### Error Logging\r\n\r\nBy default the logging is `disabled` i.e set to `false`. However, to enable logging, pass\r\n`logging=true` when you create the `oauthClient` instance :\r\n\r\n```javascript\r\nconst oauthClient = new OAuthClient({\r\n  clientId: '<Enter your clientId>',\r\n  clientSecret: '<Enter your clientSecret>',\r\n  environment: 'sandbox',\r\n  redirectUri: '<http://localhost:8000/callback>',\r\n  logging: true,\r\n});\r\n```\r\n\r\nThe logs would be captured under the directory `/logs/oAuthClient-log.log`\r\n\r\nWhenever there is an error, the library throws an exception and you can use the below helper methods\r\nto retrieve more information :\r\n\r\n```javascript\r\noauthClient.createToken(parseRedirect).catch(function (error) {\r\n  console.log(error);\r\n});\r\n\r\n/**\r\n* This is how the Error Object Looks : \r\n{  \r\n   \"originalMessage\":\"Response has an Error\",\r\n   \"error\":\"invalid_grant\",\r\n   \"error_description\":\"Token invalid\",\r\n   \"intuit_tid\":\"4245c696-3710-1548-d1e0-d85918e22ebe\"\r\n}\r\n*/\r\n```\r\n\r\n## FAQ\r\n\r\nYou can refer to our [FAQ](https://github.com/intuit/oauth-jsclient/wiki/FAQ) if you have any\r\nquestions.\r\n\r\n## Contributing\r\n\r\n- You are welcome to send a PR to `develop` branch.\r\n- The `master` branch will always point to the latest published version.\r\n- The `develop` branch will contain the latest development/testing changes.\r\n\r\n### Steps\r\n\r\n- Fork and clone the repository (`develop` branch).\r\n- Run `npm install` for dependencies.\r\n- Run `npm test` to execute all specs.\r\n\r\n## Changelog\r\n\r\nSee the changelog [here](https://github.com/intuit/oauth-jsclient/blob/master/CHANGELOG.md)\r\n\r\n## License\r\n\r\nIntuit `oauth-jsclient` is licensed under the\r\n[Apache License, Version 2.0](https://github.com/intuit/oauth-jsclient/blob/master/LICENSE)\r\n\r\n[ss1]: https://help.developer.intuit.com/s/SDKFeedback?cid=1120\r\n","readmeFilename":"README.md"}