IO-256 Authorization and Basic Calls

This commit is contained in:
Patrick Fic
2021-08-27 15:42:32 -07:00
parent 724c097d52
commit 5284ee2ef9
13 changed files with 6559 additions and 126 deletions

View File

@@ -6,6 +6,7 @@ require("dotenv").config({
),
});
const OAuthClient = require("intuit-oauth");
const logger = require("../../utils/logger");
const oauthClient = new OAuthClient({
clientId: process.env.QBO_CLIENT_ID,
@@ -16,15 +17,17 @@ const oauthClient = new OAuthClient({
exports.default = async (req, res) => {
try {
logger.log("qbo-auth-uri", "DEBUG", req.user.email, null, null);
const authUri = oauthClient.authorizeUri({
scope: [OAuthClient.scopes.Accounting, OAuthClient.scopes.OpenId],
state: req.user.uid,
state: req.user.email,
}); // can be an array of multiple scopes ex : {scope:[OAuthClient.scopes.Accounting,OAuthClient.scopes.OpenId]}
// Redirect the authUri
res.send(authUri);
} catch (error) {
console.log(error);
res.sendStatus(500);
logger.log("qbo-auth-uri-error", "ERROR", req.user.email, null, { error });
res.status(500).json(error);
}
};