diff --git a/package.json b/package.json index 9d5a2c8d..e624c1fb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "intuit-oauth", - "version": "4.1.0", + "version": "4.1.1", "description": "Intuit Node.js client for OAuth2.0 and OpenIDConnect", "main": "./src/OAuthClient.js", "scripts": { diff --git a/sample/app.js b/sample/app.js index 9c56f73f..fd57bc2a 100644 --- a/sample/app.js +++ b/sample/app.js @@ -72,7 +72,7 @@ app.get('/callback', function (req, res) { oauthClient .createToken(req.url) .then(function (authResponse) { - oauth2_token_json = JSON.stringify(authResponse.getJson(), null, 2); + oauth2_token_json = JSON.stringify(authResponse.json, null, 2); }) .catch(function (e) { console.error(e); @@ -95,8 +95,8 @@ app.get('/refreshAccessToken', function (req, res) { oauthClient .refresh() .then(function (authResponse) { - console.log(`The Refresh Token is ${JSON.stringify(authResponse.getJson())}`); - oauth2_token_json = JSON.stringify(authResponse.getJson(), null, 2); + console.log(`The Refresh Token is ${JSON.stringify(authResponse.json)}`); + oauth2_token_json = JSON.stringify(authResponse.json, null, 2); res.send(oauth2_token_json); }) .catch(function (e) { @@ -118,8 +118,8 @@ app.get('/getCompanyInfo', function (req, res) { oauthClient .makeApiCall({ url: `${url}v3/company/${companyID}/companyinfo/${companyID}` }) .then(function (authResponse) { - console.log(`The response for API call is :${JSON.stringify(authResponse)}`); - res.send(JSON.parse(authResponse.text())); + console.log(`The response for API call is :${JSON.stringify(authResponse.json)}`); + res.send(authResponse.json); }) .catch(function (e) { console.error(e); diff --git a/src/OAuthClient.js b/src/OAuthClient.js index c6b3b0d8..be7b87ed 100644 --- a/src/OAuthClient.js +++ b/src/OAuthClient.js @@ -185,7 +185,7 @@ OAuthClient.prototype.createToken = function createToken(uri) { const { response, ...authResponse } = res.json ? res : null; const json = (authResponse && authResponse.json) || res; this.token.setToken(json); - this.log('info', 'Create Token response is : ', JSON.stringify(authResponse, null, 2)); + this.log('info', 'Create Token response is : ', JSON.stringify(authResponse.json, null, 2)); return authResponse; }) .catch((e) => { @@ -224,9 +224,9 @@ OAuthClient.prototype.refresh = function refresh() { }) .then((res) => { const { request, ...authResponse } = res.json ? res : null; - const json = (authResponse && authResponse.getJson()) || res; + const json = (authResponse && authResponse.json) || res; this.token.setToken(json); - this.log('info', 'Refresh Token () response is : ', JSON.stringify(authResponse, null, 2)); + this.log('info', 'Refresh Token () response is : ', JSON.stringify(authResponse.json, null, 2)); return authResponse; }) .catch((e) => { @@ -266,7 +266,7 @@ OAuthClient.prototype.refreshUsingToken = function refreshUsingToken(refresh_tok }) .then((res) => { const { request, ...authResponse } = res.json ? res : null; - const json = (authResponse && authResponse.getJson()) || res; + const json = (authResponse && authResponse.json) || res; this.token.setToken(json); this.log( 'info', @@ -402,7 +402,7 @@ OAuthClient.prototype.makeApiCall = function makeApiCall(params) { resolve(this.getTokenRequest(request)); }) .then(({ request, ...authResponse }) => { - this.log('info', 'The makeAPICall () response is : ', JSON.stringify(authResponse, null, 2)); + this.log('info', 'The makeAPICall () response is : ', JSON.stringify(authResponse.json, null, 2)); return authResponse; }) .catch((e) => {