Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue: https://github.com/intuit/oauth-jsclient/issues/171 #174

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "intuit-oauth",
"version": "4.1.2",
"version": "4.1.3",
"description": "Intuit Node.js client for OAuth2.0 and OpenIDConnect",
"main": "./src/OAuthClient.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion sample/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ app.get('/authUri', urlencodedParser, function (req, res) {
});

const authUri = oauthClient.authorizeUri({
scope: [OAuthClient.scopes.Accounting],
scope: [OAuthClient.scopes.Accounting, OAuthClient.scopes.OpenId, OAuthClient.scopes.Profile, OAuthClient.scopes.Email],
state: 'intuit-test',
});
res.send(authUri);
Expand Down
14 changes: 7 additions & 7 deletions src/OAuthClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ OAuthClient.prototype.createToken = function createToken(uri) {
resolve(this.getTokenRequest(request));
})
.then((res) => {
const authResponse = res.json ? res : null;
const authResponse = res.hasOwnProperty('json')? res : null;
const json = (authResponse && authResponse.json) || res;
this.token.setToken(json);
this.log('info', 'Create Token response is : ', JSON.stringify(authResponse && authResponse.json, null, 2));
this.log('info', 'Create Token response is : ', JSON.stringify(authResponse && authResponse.json, null, 2));
return authResponse;
})
.catch((e) => {
Expand Down Expand Up @@ -223,7 +223,7 @@ OAuthClient.prototype.refresh = function refresh() {
resolve(this.getTokenRequest(request));
})
.then((res) => {
const authResponse = res.json ? res : null;
const authResponse = res.hasOwnProperty('json')? res : null;
const json = (authResponse && authResponse.json) || res;
this.token.setToken(json);
this.log('info', 'Refresh Token () response is : ', JSON.stringify(authResponse && 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 authResponse = res.json ? res : null;
const authResponse = res.hasOwnProperty('json')? res : null;
const json = (authResponse && authResponse.json) || res;
this.token.setToken(json);
this.log(
Expand Down Expand Up @@ -315,7 +315,7 @@ OAuthClient.prototype.revoke = function revoke(params) {
resolve(this.getTokenRequest(request));
})
.then((res) => {
const authResponse = res.json ? res : null;
const authResponse = res.hasOwnProperty('json')? res : null;
this.token.clearToken();
this.log('info', 'Revoke Token () response is : ', JSON.stringify(authResponse && authResponse.json, null, 2));
return authResponse;
Expand Down Expand Up @@ -349,7 +349,7 @@ OAuthClient.prototype.getUserInfo = function getUserInfo() {
resolve(this.getTokenRequest(request));
})
.then((res) => {
const authResponse = res.json ? res : null;
const authResponse = res.hasOwnProperty('json')? res : null;
this.log(
'info',
'The Get User Info () response is : ', JSON.stringify(authResponse && authResponse.json, null, 2),
Expand Down Expand Up @@ -456,7 +456,7 @@ OAuthClient.prototype.validateIdToken = function validateIdToken(params = {}) {
return resolve(this.getKeyFromJWKsURI(id_token, id_token_header.kid, request));
})
.then((res) => {
this.log('info', 'The validateIdToken () response is : ', JSON.stringify(res, null, 2));
this.log('info', 'The validateIdToken () response is :', JSON.stringify(res, null, 2));
if (res) return true;
return false;
})
Expand Down