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

Add all scopes as optional #1

Closed
wants to merge 1 commit into from
Closed
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
16 changes: 16 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ const CLIENT_ID = process.env.CLIENT_ID;
const CLIENT_SECRET = process.env.CLIENT_SECRET;

const SCOPES = ['contacts'].join(' ');
const OPTIONAL_SCOPES = [
"automation",
"business-intelligence",
"content",
"e-commerce",
"files",
"forms",
"hubdb",
"integration-sync",
"social",
"tickets",
"timeline",
"transactional-email",
].join(' ')

const REDIRECT_URI = `http://localhost:${PORT}/oauth-callback`;

const refreshTokenStore = {};
Expand All @@ -30,6 +45,7 @@ const authUrl =
'https://app.hubspot.com/oauth/authorize' +
`?client_id=${encodeURIComponent(CLIENT_ID)}` + // app's client ID
`&scope=${encodeURIComponent(SCOPES)}` + // scopes being requested by the app
`&optional_scope=${encodeURIComponent(OPTIONAL_SCOPES)}` +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This query parameter should only be added if there are optional scopes being requested

`&redirect_uri=${encodeURIComponent(REDIRECT_URI)}`; // where to send the user after the consent page

// Redirect the user from the installation page to
Expand Down