Skip to content

Commit

Permalink
Fix for issue#167, updated documentation, and removed unused var
Browse files Browse the repository at this point in the history
  • Loading branch information
rgupta24723 committed Mar 21, 2024
1 parent 6ad9b49 commit 961be29
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -232,7 +232,7 @@ You can call the below helper method to refresh tokens by explictly passing the
oauthClient
.refreshUsingToken('<Enter the refresh token>')
.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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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();
});
```
Expand Down
12 changes: 6 additions & 6 deletions src/OAuthClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 : ',
Expand Down Expand Up @@ -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;
})
Expand Down

0 comments on commit 961be29

Please sign in to comment.