Skip to content

Commit 1e16fa9

Browse files
waleedlatif1claude
andcommitted
fix(box): populate OAuth scopes for Box since token response omits them
Box's OAuth2 token endpoint does not return a scope field in the response, so Better Auth stores nothing in the DB. This causes the credential selector to always show "Additional permissions required". Fix by populating the scope from the requested scopes in the account.create.before hook. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 17723bb commit 1e16fa9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

apps/sim/lib/auth/auth.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,16 @@ export const auth = betterAuth({
211211
modifiedAccount.refreshTokenExpiresAt = getMicrosoftRefreshTokenExpiry()
212212
}
213213

214+
// Box token response does not include a scope field, so Better Auth
215+
// stores nothing. Populate it from the requested scopes so the
216+
// credential-selector can verify permissions.
217+
if (account.providerId === 'box' && !account.scope) {
218+
const requestedScopes = getCanonicalScopesForProvider('box')
219+
if (requestedScopes.length > 0) {
220+
modifiedAccount.scope = requestedScopes.join(' ')
221+
}
222+
}
223+
214224
return { data: modifiedAccount }
215225
},
216226
after: async (account) => {

0 commit comments

Comments
 (0)