Skip to content

Commit ce3d2d5

Browse files
waleedlatif1claude
andauthored
fix(oauth): fall back to configured scopes when DB scope is empty (#3678)
Providers like Box don't return a scope field in their token response, leaving the account.scope column empty. The credentials API now falls back to the provider's configured scopes when the stored scope is empty, preventing false "Additional permissions required" banners. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 507954c commit ce3d2d5

File tree

1 file changed

+8
-1
lines changed
  • apps/sim/app/api/auth/oauth/credentials

1 file changed

+8
-1
lines changed

apps/sim/app/api/auth/oauth/credentials/route.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { z } from 'zod'
77
import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid'
88
import { generateRequestId } from '@/lib/core/utils/request'
99
import { syncWorkspaceOAuthCredentialsForUser } from '@/lib/credentials/oauth'
10+
import { getCanonicalScopesForProvider } from '@/lib/oauth/utils'
1011
import { authorizeWorkflowByWorkspacePermission } from '@/lib/workflows/utils'
1112
import { checkWorkspaceAccess } from '@/lib/workspaces/permissions/utils'
1213

@@ -38,7 +39,13 @@ function toCredentialResponse(
3839
scope: string | null
3940
) {
4041
const storedScope = scope?.trim()
41-
const scopes = storedScope ? storedScope.split(/[\s,]+/).filter(Boolean) : []
42+
// Some providers (e.g. Box) don't return scopes in their token response,
43+
// so the DB column stays empty. Fall back to the configured scopes for
44+
// the provider so the credential-selector doesn't show a false
45+
// "Additional permissions required" banner.
46+
const scopes = storedScope
47+
? storedScope.split(/[\s,]+/).filter(Boolean)
48+
: getCanonicalScopesForProvider(providerId)
4249
const [_, featureType = 'default'] = providerId.split('-')
4350

4451
return {

0 commit comments

Comments
 (0)