diff --git a/lib/auth.ts b/lib/auth.ts index 0f7517e295..1f5d5f4a90 100644 --- a/lib/auth.ts +++ b/lib/auth.ts @@ -104,6 +104,8 @@ export const auth = betterAuth({ clientId: process.env.GITHUB_CLIENT_ID as string, clientSecret: process.env.GITHUB_CLIENT_SECRET as string, authorizationUrl: 'https://github.com/login/oauth/authorize', + accessType: 'offline', + prompt: 'consent', tokenUrl: 'https://github.com/login/oauth/access_token', userInfoUrl: 'https://api.github.com/user', scopes: ['user:email', 'repo'], @@ -113,9 +115,11 @@ export const auth = betterAuth({ clientId: process.env.GITHUB_CLIENT_ID as string, clientSecret: process.env.GITHUB_CLIENT_SECRET as string, authorizationUrl: 'https://github.com/login/oauth/authorize', + accessType: 'offline', tokenUrl: 'https://github.com/login/oauth/access_token', userInfoUrl: 'https://api.github.com/user', scopes: ['workflow', 'repo'], + prompt: 'consent', }, // Google providers for different purposes @@ -124,55 +128,65 @@ export const auth = betterAuth({ clientId: process.env.GOOGLE_CLIENT_ID as string, clientSecret: process.env.GOOGLE_CLIENT_SECRET as string, discoveryUrl: 'https://accounts.google.com/.well-known/openid-configuration', + accessType: 'offline', scopes: [ 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/gmail.send', ], + prompt: 'consent', }, { providerId: 'google-calendar', clientId: process.env.GOOGLE_CLIENT_ID as string, clientSecret: process.env.GOOGLE_CLIENT_SECRET as string, discoveryUrl: 'https://accounts.google.com/.well-known/openid-configuration', + accessType: 'offline', scopes: [ 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/calendar', ], + prompt: 'consent', }, { providerId: 'google-drive', clientId: process.env.GOOGLE_CLIENT_ID as string, clientSecret: process.env.GOOGLE_CLIENT_SECRET as string, discoveryUrl: 'https://accounts.google.com/.well-known/openid-configuration', + accessType: 'offline', scopes: [ 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/drive', ], + prompt: 'consent', }, { providerId: 'google-docs', clientId: process.env.GOOGLE_CLIENT_ID as string, clientSecret: process.env.GOOGLE_CLIENT_SECRET as string, discoveryUrl: 'https://accounts.google.com/.well-known/openid-configuration', + accessType: 'offline', scopes: [ 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/documents', ], + prompt: 'consent', }, { providerId: 'google-sheets', clientId: process.env.GOOGLE_CLIENT_ID as string, clientSecret: process.env.GOOGLE_CLIENT_SECRET as string, discoveryUrl: 'https://accounts.google.com/.well-known/openid-configuration', + accessType: 'offline', scopes: [ 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/spreadsheets', ], + prompt: 'consent', }, // Supabase provider @@ -181,6 +195,7 @@ export const auth = betterAuth({ clientId: process.env.SUPABASE_CLIENT_ID as string, clientSecret: process.env.SUPABASE_CLIENT_SECRET as string, authorizationUrl: 'https://api.supabase.com/v1/oauth/authorize', + accessType: 'offline', tokenUrl: 'https://api.supabase.com/v1/oauth/token', userInfoUrl: 'https://api.supabase.com/v1/oauth/userinfo', scopes: ['database.read', 'database.write', 'projects.read'], @@ -196,6 +211,7 @@ export const auth = betterAuth({ authorizationUrl: 'https://x.com/i/oauth2/authorize', tokenUrl: 'https://api.x.com/2/oauth2/token', userInfoUrl: 'https://api.x.com/2/users/me', + accessType: 'offline', scopes: ['tweet.read', 'tweet.write', 'users.read', 'offline.access'], pkce: true, redirectURI: `${process.env.NEXT_PUBLIC_APP_URL}/api/auth/oauth2/callback/x`,