diff --git a/README.md b/README.md index 88f8b177..d7c0dd46 100644 --- a/README.md +++ b/README.md @@ -163,7 +163,7 @@ const parseRedirect = req.url; oauthClient .createToken(parseRedirect) .then(function (authResponse) { - console.log('The Token is ' + JSON.stringify(authResponse.getJson())); + console.log('The Token is ' + JSON.stringify(authResponse.json)); }) .catch(function (e) { console.error('The error message is :' + e.originalMessage); @@ -215,7 +215,7 @@ previous refresh tokens expire 24 hours after you receive a new one. oauthClient .refresh() .then(function (authResponse) { - console.log('Tokens refreshed : ' + JSON.stringify(authResponse.getJson())); + console.log('Tokens refreshed : ' + JSON.stringify(authResponse.json)); }) .catch(function (e) { console.error('The error message is :' + e.originalMessage); @@ -232,7 +232,7 @@ You can call the below helper method to refresh tokens by explictly passing the oauthClient .refreshUsingToken('') .then(function (authResponse) { - console.log('Tokens refreshed : ' + JSON.stringify(authResponse.getJson())); + console.log('Tokens refreshed : ' + JSON.stringify(authResponse.json)); }) .catch(function (e) { console.error('The error message is :' + e.originalMessage); @@ -249,7 +249,7 @@ tokens. oauthClient .revoke() .then(function (authResponse) { - console.log('Tokens revoked : ' + JSON.stringify(authResponse.getJson())); + console.log('Tokens revoked : ' + JSON.stringify(authResponse.json)); }) .catch(function (e) { console.error('The error message is :' + e.originalMessage); @@ -265,7 +265,7 @@ how to retrieve the `token` object oauthClient .revoke(params) .then(function (authResponse) { - console.log('Tokens revoked : ' + JSON.stringify(authResponse.getJson())); + console.log('Tokens revoked : ' + JSON.stringify(authResponse.json)); }) .catch(function (e) { console.error('The error message is :' + e.originalMessage); @@ -509,10 +509,10 @@ You can use the below helper methods to make full use of the Auth Response Objec ```javascript oauthClient.createToken(parseRedirect).then(function (authResponse) { - console.log('The Token in JSON is ' + JSON.stringify(authResponse.getJson())); + console.log('The Token in JSON is ' + JSON.stringify(authResponse.json)); let status = authResponse.status(); let body = authResponse.text(); - let jsonResponse = authResponse.getJson(); + let jsonResponse = authResponse.json; let intuit_tid = authResponse.get_intuit_tid(); }); ``` diff --git a/sample/app.js b/sample/app.js index fd57bc2a..77f1440a 100644 --- a/sample/app.js +++ b/sample/app.js @@ -95,7 +95,7 @@ app.get('/refreshAccessToken', function (req, res) { oauthClient .refresh() .then(function (authResponse) { - console.log(`The Refresh Token is ${JSON.stringify(authResponse.json)}`); + console.log(`\n The Refresh Token is ${JSON.stringify(authResponse.json)}`); oauth2_token_json = JSON.stringify(authResponse.json, null, 2); res.send(oauth2_token_json); }) @@ -118,7 +118,7 @@ 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.json)}`); + console.log(`\n The response for API call is :${JSON.stringify(authResponse.json)}`); res.send(authResponse.json); }) .catch(function (e) { diff --git a/src/OAuthClient.js b/src/OAuthClient.js index 7cf12f32..cfe73f9c 100644 --- a/src/OAuthClient.js +++ b/src/OAuthClient.js @@ -182,7 +182,7 @@ OAuthClient.prototype.createToken = function createToken(uri) { resolve(this.getTokenRequest(request)); }) .then((res) => { - const { response, ...authResponse } = res.json ? res : null; + const 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.json, null, 2)); @@ -223,7 +223,7 @@ OAuthClient.prototype.refresh = function refresh() { resolve(this.getTokenRequest(request)); }) .then((res) => { - const { request, ...authResponse } = res.json ? res : null; + const authResponse = res.json ? res : null; const json = (authResponse && authResponse.json) || res; this.token.setToken(json); this.log('info', 'Refresh Token () response is : ', JSON.stringify(authResponse.json, null, 2)); @@ -265,7 +265,7 @@ OAuthClient.prototype.refreshUsingToken = function refreshUsingToken(refresh_tok resolve(this.getTokenRequest(request)); }) .then((res) => { - const { request, ...authResponse } = res.json ? res : null; + const authResponse = res.json ? res : null; const json = (authResponse && authResponse.json) || res; this.token.setToken(json); this.log( @@ -316,7 +316,7 @@ OAuthClient.prototype.revoke = function revoke(params) { resolve(this.getTokenRequest(request)); }) .then((res) => { - const { request, ...authResponse } = res.json ? res : null; + const authResponse = res.json ? res : null; this.token.clearToken(); this.log('info', 'Revoke Token () response is : ', JSON.stringify(authResponse.json, null, 2)); return authResponse; @@ -350,7 +350,7 @@ OAuthClient.prototype.getUserInfo = function getUserInfo() { resolve(this.getTokenRequest(request)); }) .then((res) => { - const { request, ...authResponse } = res.json ? res : null; + const authResponse = res.json ? res : null; this.log( 'info', 'The Get User Info () response is : ', @@ -403,7 +403,7 @@ OAuthClient.prototype.makeApiCall = function makeApiCall(params) { resolve(this.getTokenRequest(request)); }) .then((res) => { - const { request, ...authResponse } = res.json ? res : null; + const authResponse = res.json ? res : null; this.log('info', 'The makeAPICall () response is : ', JSON.stringify(authResponse.json, null, 2)); return authResponse; })