Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
app.get('/disconnect', function(req,res){
console.log('The disconnect called ');
const authUri = oauthClient.authorizeUri({scope:[OAuthClient.scopes.OpenId,OAuthClient.scopes.Email],state:'intuit-test'});
res.redirect(authUri);
});
app.get('/getCompanyInfo', function(req,res){
const companyID = oauthClient.getToken().realmId;
const url = oauthClient.environment == 'sandbox' ? OAuthClient.environment.sandbox : OAuthClient.environment.production ;
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()));
})
.catch(function(e) {
console.error(e);
});
});
app.get('/authUri', urlencodedParser, function(req,res) {
oauthClient = new OAuthClient({
clientId: req.query.json.clientId,
clientSecret: req.query.json.clientSecret,
environment: req.query.json.environment,
redirectUri: req.query.json.redirectUri
});
const authUri = oauthClient.authorizeUri({scope:[OAuthClient.scopes.Accounting],state:'intuit-test'});
res.send(authUri);
});