Twitter OAuth not returning email despite proper configuration

I'm using better-auth with Twitter OAuth and can't get the email address from users. I've set up everything according to docs but still getting:

ERROR [Better Auth]: Provider did not return email. This could be due to misconfiguration in the provider settings.


What I've done:

  • Enabled "Request email from users" in Twitter dev portal
  • Set up app as "Web App" with "Confidential client"
  • Set callback URL to http://localhost:3000/api/auth/callback/twitter
  • Been following this guide: https://www.better-auth.com/docs/authentication/twitter
## Current code:
twitter: {
  clientId: process.env.TWITTER_CLIENT_ID as string,
  clientSecret: process.env.TWITTER_CLIENT_SECRET as string,
  mapProfileToUser: (profile: TwitterProfile) => {
    console.log("profile", profile);
    return {
      twitterHandle: profile.username,
      email: profile.email as string,
      name: profile.name as string,
      image: profile.profile_image_url as string,
      username: profile.username,
    };
  },
}


What I'm getting:

@repo/web:dev: profile {
@repo/web:dev:   data: {
@repo/web:dev:     name: 'Robin Faraj',
@repo/web:dev:     profile_image_url: 'https://pbs.twimg.com/profile_images/1855238561395544064/xZgBtaNg_normal.jpg',
@repo/web:dev:     username: 'robin_faraj',
@repo/web:dev:     id: '2517496955'
@repo/web:dev:   }
@repo/web:dev: }


No email in the profile data. How can I get Twitter to return the email address with better-auth? Is this a Twitter API limitation or a configuration issue?

Any help appreciated!
Twitter provider setup and usage.
Was this page helpful?