Skip to content

Commit b1d0492

Browse files
Adam GoughAdam Gough
authored andcommitted
oauth required modal
1 parent 09594d1 commit b1d0492

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

  • apps/sim
    • app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/credential-selector/components
    • lib

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/credential-selector/components/oauth-required-modal.tsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,48 @@ const SCOPE_DESCRIPTIONS: Record<string, string> = {
189189
'sites:write': 'Manage webhooks and site settings',
190190
'cms:read': 'View your CMS content',
191191
'cms:write': 'Manage your CMS content',
192+
'crm.objects.contacts.read': 'Read your HubSpot contacts',
193+
'crm.objects.contacts.write': 'Create and update HubSpot contacts',
194+
'crm.objects.companies.read': 'Read your HubSpot companies',
195+
'crm.objects.companies.write': 'Create and update HubSpot companies',
196+
'crm.objects.deals.read': 'Read your HubSpot deals',
197+
'crm.objects.deals.write': 'Create and update HubSpot deals',
198+
'crm.objects.owners.read': 'Read HubSpot object owners',
199+
'crm.objects.users.read': 'Read HubSpot users',
200+
'crm.objects.users.write': 'Create and update HubSpot users',
201+
'crm.objects.marketing_events.read': 'Read HubSpot marketing events',
202+
'crm.objects.marketing_events.write': 'Create and update HubSpot marketing events',
203+
'crm.objects.line_items.read': 'Read HubSpot line items',
204+
'crm.objects.line_items.write': 'Create and update HubSpot line items',
205+
'crm.objects.quotes.read': 'Read HubSpot quotes',
206+
'crm.objects.quotes.write': 'Create and update HubSpot quotes',
207+
'crm.objects.appointments.read': 'Read HubSpot appointments',
208+
'crm.objects.appointments.write': 'Create and update HubSpot appointments',
209+
'crm.objects.carts.read': 'Read HubSpot shopping carts',
210+
'crm.objects.carts.write': 'Create and update HubSpot shopping carts',
211+
'crm.import': 'Import data into HubSpot',
212+
'crm.lists.read': 'Read HubSpot lists',
213+
'crm.lists.write': 'Create and update HubSpot lists',
214+
tickets: 'Manage HubSpot tickets',
215+
api: 'Access Salesforce API',
216+
full: 'Full access to your Salesforce data',
217+
refresh_token: 'Maintain long-term access to your Salesforce account',
218+
default: 'Access your Asana workspace',
219+
base: 'Basic access to your Pipedrive account',
220+
'deals:read': 'Read your Pipedrive deals',
221+
'deals:full': 'Full access to manage your Pipedrive deals',
222+
'contacts:read': 'Read your Pipedrive contacts',
223+
'contacts:full': 'Full access to manage your Pipedrive contacts',
224+
'leads:read': 'Read your Pipedrive leads',
225+
'leads:full': 'Full access to manage your Pipedrive leads',
226+
'activities:read': 'Read your Pipedrive activities',
227+
'activities:full': 'Full access to manage your Pipedrive activities',
228+
'mail:read': 'Read your Pipedrive emails',
229+
'mail:full': 'Full access to manage your Pipedrive emails',
230+
'projects:read': 'Read your Pipedrive projects',
231+
'projects:full': 'Full access to manage your Pipedrive projects',
232+
'webhooks:read': 'Read your Pipedrive webhooks',
233+
'webhooks:full': 'Full access to manage your Pipedrive webhooks',
192234
}
193235

194236
function getScopeDescription(scope: string): string {

apps/sim/lib/auth.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,7 @@ export const auth = betterAuth({
671671
authorizationUrl: 'https://oauth.pipedrive.com/oauth/authorize',
672672
tokenUrl: 'https://oauth.pipedrive.com/oauth/token',
673673
userInfoUrl: 'https://api.pipedrive.com/v1/users/me',
674+
prompt: 'consent',
674675
scopes: [
675676
'base',
676677
'deals:read',
@@ -734,6 +735,9 @@ export const auth = betterAuth({
734735
authorizationUrl: 'https://app.hubspot.com/oauth/authorize',
735736
tokenUrl: 'https://api.hubapi.com/oauth/v1/token',
736737
userInfoUrl: 'https://api.hubapi.com/oauth/v1/access-tokens',
738+
prompt: 'consent',
739+
responseType: 'code',
740+
overrideUserInfo: true,
737741
scopes: [
738742
'crm.objects.contacts.read',
739743
'crm.objects.contacts.write',
@@ -777,6 +781,14 @@ export const auth = betterAuth({
777781

778782
const data = await response.json()
779783

784+
logger.info('HubSpot token metadata response:', {
785+
hasScopes: !!data.scopes,
786+
scopesType: typeof data.scopes,
787+
scopesIsArray: Array.isArray(data.scopes),
788+
scopesValue: data.scopes,
789+
fullResponse: data,
790+
})
791+
780792
return {
781793
id: data.user_id || data.hub_id.toString(),
782794
name: data.user || 'HubSpot User',
@@ -785,6 +797,11 @@ export const auth = betterAuth({
785797
image: undefined,
786798
createdAt: new Date(),
787799
updatedAt: new Date(),
800+
// Extract scopes from HubSpot's response and convert array to space-delimited string
801+
// Use 'scope' (singular) as that's what better-auth expects for the account table
802+
...(data.scopes && Array.isArray(data.scopes)
803+
? { scope: data.scopes.join(' ') }
804+
: {}),
788805
}
789806
} catch (error) {
790807
logger.error('Error creating HubSpot user profile:', { error })
@@ -803,6 +820,7 @@ export const auth = betterAuth({
803820
userInfoUrl: 'https://login.salesforce.com/services/oauth2/userinfo',
804821
scopes: ['api', 'full', 'openid', 'refresh_token', 'offline_access'],
805822
pkce: true,
823+
prompt: 'consent',
806824
redirectURI: `${getBaseUrl()}/api/auth/oauth2/callback/salesforce`,
807825
getUserInfo: async (tokens) => {
808826
try {

0 commit comments

Comments
 (0)