Skip to content

Commit 90c34b2

Browse files
authored
fix(airtable): fix airtable oauth connection (#1682)
1 parent 3a0019b commit 90c34b2

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

apps/sim/lib/auth.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,38 @@ export const auth = betterAuth({
947947
authentication: 'basic',
948948
prompt: 'consent',
949949
redirectURI: `${getBaseUrl()}/api/auth/oauth2/callback/airtable`,
950+
getUserInfo: async (tokens) => {
951+
try {
952+
const response = await fetch('https://api.airtable.com/v0/meta/whoami', {
953+
headers: {
954+
Authorization: `Bearer ${tokens.accessToken}`,
955+
},
956+
})
957+
958+
if (!response.ok) {
959+
logger.error('Error fetching Airtable user info:', {
960+
status: response.status,
961+
statusText: response.statusText,
962+
})
963+
return null
964+
}
965+
966+
const data = await response.json()
967+
const now = new Date()
968+
969+
return {
970+
id: data.id,
971+
name: data.email ? data.email.split('@')[0] : 'Airtable User',
972+
email: data.email || `${data.id}@airtable.user`,
973+
emailVerified: !!data.email,
974+
createdAt: now,
975+
updatedAt: now,
976+
}
977+
} catch (error) {
978+
logger.error('Error in Airtable getUserInfo:', { error })
979+
return null
980+
}
981+
},
950982
},
951983

952984
// Notion provider

0 commit comments

Comments
 (0)