diff --git a/docs/content/docs/authentication/twitter.mdx b/docs/content/docs/authentication/twitter.mdx index 67f06b2709..79f7a68917 100644 --- a/docs/content/docs/authentication/twitter.mdx +++ b/docs/content/docs/authentication/twitter.mdx @@ -9,6 +9,15 @@ description: Twitter provider setup and usage. Get your Twitter credentials from the [Twitter Developer Portal](https://developer.twitter.com/en/portal/dashboard). Make sure to set the redirect URL to `http://localhost:3000/api/auth/callback/twitter` for local development. For production, you should set it to the URL of your application. If you change the base path of the auth routes, you should update the redirect URL accordingly. + + {/* + + If twitter doesn't return the email address, the authentication won't be successful. Make sure to ask for the email address when you create the Twitter app. + + */} + + Twitter API v2 does not provide email addresses. As a workaround, the user's `email` field uses the `username` value instead. + @@ -43,8 +52,5 @@ description: Twitter provider setup and usage. }) } ``` - - If twitter doesn't return the email address, the authentication won't be successful. Make sure to ask for the email address when you create the Twitter app. - diff --git a/packages/better-auth/src/social-providers/twitter.ts b/packages/better-auth/src/social-providers/twitter.ts index 9205ad14aa..3ac0006bac 100644 --- a/packages/better-auth/src/social-providers/twitter.ts +++ b/packages/better-auth/src/social-providers/twitter.ts @@ -144,7 +144,7 @@ export const twitter = (options: TwitterOption) => { user: { id: profile.data.id, name: profile.data.name, - email: profile.data.email || null, + email: profile.data.username || null, image: profile.data.profile_image_url, emailVerified: profile.data.verified || false, },