You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Twitter OAuth signup fails if user has no email on their twitter account #2853
If a twitter user doesn't have their email address connected to their twitter account, supabase's twitter OAuth integration fails on signup with the message "Error getting user email from external provider'.
To Reproduce
I used the nextjs-auth-tailwind example and selected 'twitter' as the OAuth provider.
appended to the URL. This is the same error that appears if you try and sign up with a fully-verified twitter account but don't have 'request email' enabled.
I have obviously enabled 'request email address' in my twitter OAuth settings, as supabase also fails if this isn't done. That said, it would be nice for this not to be necessary. Is this possible? Seems like it'd also fix this 'bug'.
Expected behavior
For the user to sign up normally. My app doesn't need a user's email, just their twitter account.
Additional context
I'm not sure if this is by design, but it is semi-breaking for my app as many twitter users don't have an email address. My app needs to be able to connect to the user's twitter account to look up lists and tweets on their behalf, and I can't do this if they don't have a verified twitter account.
Perhaps there may be a temporary fix if I'm able to change what supabase does under the hood to convert the twitter authorization to a supabase user. I'm not too familiar with supabase so not too sure how to do this. That said, would like it to work regardless (but understand it may break supabase based on design decisions).
If this isn't expected to be a super difficult fix, would appreciate being pointed in the right direction and can try and fix it myself (if it's even considered a bug)
Reacted by Austin Malerba, Ramya Chinnadurai, Shunta Takemoto, Guillaume, Aaron Conlon, Dennis Zoma, Lydia Lane and johnny-emp
I have also investigated this but have no time to post and explain. But here it is.
Problems:
Some External Auth Provider doesn't require or provider email address
Supabase looks like extremely rely on email as Unique Identifier of User (Very problematic)
To explain:
External auth provider nowadays doesn't require email for their sign up process. Example FB and Twitter doesn't require email, some user can sign up using phone numbers. Does this cause the bug explained by @fortydegrees above. This is very critical as I have encounter this issue when using firebase where I use security rules to require email but not knowing that emails are only really optional. The result? 1 to 3 stars rating from angry user for those who cant sign up because they dont have email address on their auth provider while others can sign up. This gives a bad impression to the app. And those people who cannot sign up are less likely to comeback again.
What is problematic here?
If supabase heavily rely on user email as a unique identifier of user from external auth. They are doing it wrong. External providers return UID instead that must be the one to be used instead of email as a identifier. Now, I wonder if supabase is really saving the external provider auth uid or just the email. Because if its not, then all the existing user has no UID saved on supabase
In comparison with Firebase
The user class of firebase auth has a list of provider field which is structured like this
Note: all question mark are optional/nullable because firebase doesnt expect other providers to return this from authentication instead they focus on providerId and uid.
providerId values are: 'facebook', 'twitter', 'google', 'github', 'apple', etc...
while uid values are the uid of the user from the external providers.
What is the importance of this two fields?
Now if we signed in via facebook for example -> we can look up on this fields uid and providerId
Hey @sandbox-apps - this is technically possible, as long as the user has the same email for all accounts (since this is the primary login mechanism).
For example
user logs in with email '[email protected]'
user logs in with Facebook OAuth and their facebook account has the email '[email protected]'
Both of these will return the same user uuid.
Hey @sandbox-apps - this is technically possible, as long as the user has the same email for all accounts (since this is the primary login mechanism).
This is where I first felt the concern where I have read this email for all accounts (since this is the primary login mechanism).
I think this should be structured as
Sign In via
Email and Password -> email and password lookup -> return Supabase auth uid
Facebook -> facebook will return the User UID -> UID and providerId (which is 'facebook') to lookup -> return Supabase auth uid
Twitter -> twitter will return the User UID -> UID and providerId (which is 'twitter') to lookup -> return Supabase auth uid
Google -> google will return the User UID -> UID and providerId (which is 'google') to lookup -> return Supabase auth uid
Apple -> apple will return the User UID -> UID and providerId (which is 'apple') to lookup -> return Supabase auth uid
One way to turn this bug into a feature request could be to let us choose what supabase does with the received data from the OAuth provider - like what data to request and store about the user. I assume this is similar to what firebase does, e.g. being able to map fields to our supabase auth system.
Reacted by erl-minilabs, Lydia Lane, Courage Research and Ekim Cem Ülger
I dont know about that @fortydegrees but firebase map its receive data automatically on auth system. But one thing you can do is use onAuthCreate on firebase functions to map it on firestore however you like
Edit:
I guess that is possible for every different set of permission you want to pass to access certain field/values but that would be very big task for supabase if ever.
I still prefer to just get the bare minimum like provider, uid, name, displayName after that I will just implement form in my app to ask for different types of info
For me the issue with GitHub was because of a missing permission inside the GitHub Application. Just set the "email access" field to "read only" and it works as supposed.
Reacted by João Pedro Silva , erl-minilabs, Paul Ottum, Szymon Wojdat, deankemball and Andreas
Reacted by Szymon Wojdat and Andreas
Reacted by João Pedro Silva , Szymon Wojdat and Andreas
importsupabaseAdminfrom"@/libs/supabaseAdmin"import{getURL}from"@/utils/helpers"import{createRouteHandlerClient}from"@supabase/auth-helpers-nextjs"import{cookies}from"next/headers"import{NextResponse}from"next/server"exportasyncfunctionGET(request: Request){constrequestUrl=newURL(request.url)constcode=requestUrl.searchParams.get("code")//If supabase put something in error_description - show it on error pageconsterror_description=requestUrl.searchParams.get("error_description")if(error_description){constsupabase_error_description=encodeURIComponent(error_description)returnNextResponse.redirect(`${requestUrl.origin}/error?error_description=${supabase_error_description}`)}// exchange cookies for session and set avatar urlif(code){constsupabase=createRouteHandlerClient({ cookies })constresponse=awaitsupabase.auth.exchangeCodeForSession(code)if(response.data.user&&response.data.user.email){// Insert row if user doesn't existawaitsupabaseAdmin.from("users").insert({id: response.data.user.id,username: response.data.user.user_metadata.name,email: response.data.user.email,email_confirmed_at: response.data.user.email_confirmed_at,})// Replace avatar_url if !avatar_urlconst{ data,error: selectAvatarError}=awaitsupabaseAdmin.from("users").select("avatar_url").eq("email",response.data.user.email).single()if(selectAvatarError)throwselectAvatarErrorif(!data?.avatar_url){awaitsupabaseAdmin.from("users").update({email_confirmed_at: response.data.user.updated_at,avatar_url: response.data.user.user_metadata.avatar_url,}).eq("id",response.data.user.id)}}else{consterror_description=encodeURIComponent("No user found after exchanging cookies for registration")returnNextResponse.redirect(`${requestUrl.origin}/error?error_description=${error_description}`)}}returnNextResponse.redirect(`${getURL()}`)}
So this was never resolved correct? I'm not the most code savy but I encounter this same issue using WeWeb.io, a no code frontend that integrates with Supabase and Supabase Auth. I'm building an app specific to the Twitter (X) community, however, during debugging, I couldn't even log in to my own app because I don't have an email associated with my Twitter account (lol right). For creators like me, who currently rely on no-code solutions to move quickly, would love to use Supabase because of how friendly the pricing is, compared to other platforms like Xano (which are also more difficult to implement in my opinion). So is there any movement on no-email twitter login or is this officially dead?
30% of users on X do not have emails associated to their account.
OAuth being unusable on 30% of the target platform means a non-functioning faulty product, it is not an edge-case that can be safely ignored for 3 years @kiwicopple@joshenlim
Hey folks! I understand your frustration as exemplified by this:
it is not an edge-case that can be safely ignored for 3 years
The team agrees with this. However, removing the dependence on email addresses is slowly in progress and we expect to ramp up and finish it in the next period. I can go in to why it's so challenging on our end, but we've already resolved most of the biggest challenges so there's not much more to do to lift the restriction.
Thank you for being patient with us!
Reacted by the_magician, exit, Matheus Seabra, Boning and Gianluca
Activity
sandbox-apps commentedon Aug 17, 2021
I have also investigated this but have no time to post and explain. But here it is.
Problems:
To explain:
External auth provider nowadays doesn't require email for their sign up process. Example FB and Twitter doesn't require email, some user can sign up using phone numbers. Does this cause the bug explained by @fortydegrees above. This is very critical as I have encounter this issue when using firebase where I use security rules to require email but not knowing that emails are only really optional. The result? 1 to 3 stars rating from angry user for those who cant sign up because they dont have email address on their auth provider while others can sign up. This gives a bad impression to the app. And those people who cannot sign up are less likely to comeback again.
What is problematic here?
If supabase heavily rely on user email as a unique identifier of user from external auth. They are doing it wrong. External providers return UID instead that must be the one to be used instead of email as a identifier. Now, I wonder if supabase is really saving the external provider auth uid or just the email. Because if its not, then all the existing user has no UID saved on supabase
In comparison with Firebase
The user class of firebase auth has a list of provider field which is structured like this
Note: all question mark are optional/nullable because firebase doesnt expect other providers to return this from authentication instead they focus on providerId and uid.
providerId values are: 'facebook', 'twitter', 'google', 'github', 'apple', etc...
while uid values are the uid of the user from the external providers.
What is the importance of this two fields?
Now if we signed in via facebook for example -> we can look up on this fields uid and providerId
To know more about this: https://pub.dev/documentation/firebase_auth/latest/firebase_auth/User-class.html
I feel like you feel overconfident about one liner sign up/sign in process and overlook this kind of mistakes.
sandbox-apps commentedon Aug 17, 2021
To add on with this problem.
https://github.com/supabase/supabase/issues/2556
Hey @sandbox-apps - this is technically possible, as long as the user has the same email for all accounts (since this is the primary login mechanism).
This is where I first felt the concern where I have read this
email for all accounts (since this is the primary login mechanism).I think this should be structured as
Sign In via
sandbox-apps commentedon Aug 17, 2021
TLDR: all those who dont have email address on every social auth provider cannot use social auth provider right now.
sandbox-apps commentedon Aug 17, 2021
This is what its like if the user has no email address
https://github.com/firebase/snippets-web/blob/c5bfca32e881d7a40002285384a784749f973c35/snippets/auth-next/manage/auth_get_user_profile_provider.js#L8-L21
fortydegrees commentedon Aug 17, 2021
One way to turn this bug into a feature request could be to let us choose what supabase does with the received data from the OAuth provider - like what data to request and store about the user. I assume this is similar to what firebase does, e.g. being able to map fields to our supabase auth system.
sandbox-apps commentedon Aug 17, 2021
I dont know about that @fortydegrees but firebase map its receive data automatically on auth system. But one thing you can do is use onAuthCreate on firebase functions to map it on firestore however you like
Edit:
I guess that is possible for every different set of permission you want to pass to access certain field/values but that would be very big task for supabase if ever.
I still prefer to just get the bare minimum like provider, uid, name, displayName after that I will just implement form in my app to ask for different types of info
shinriyo commentedon Oct 24, 2021
same error when I use GitHub.
camiaei commentedon Oct 27, 2021
I'm facing a similar issue: I want to use the Twitter OAuth Provider, but I don't want my users to be forced to show me their email address.
kennethcassel commentedon Nov 19, 2021
not using email as the unique identifier could also allow folks to use things like wallet addresses. Would love to sign up users without an email
maximkott commentedon Dec 16, 2021
Happens for me too when using GitHub as OAuth provider 😔
maximkott commentedon Dec 16, 2021
For me the issue with GitHub was because of a missing permission inside the GitHub Application. Just set the "email access" field to "read only" and it works as supposed.
kiwicopple commentedon Dec 28, 2021
this one is a duplicate of supabase/auth#214
Closing in favour of the gotrue issue
mijorus commentedon Nov 4, 2022
Looks like it was related to twitter's new API policies:
I had to enable this:
https://developer.twitter.com/en/portal/products/elevated
nicitaacom commentedon Nov 16, 2023
I have the same issue - I use twitter

nicitaacom commentedon Nov 16, 2023
Guide how to fix this error if you use twitter provider
Step 1 - https://developer.twitter.com/en
Step 2
Step 3
Step 4
To do this you need to deploy your app on vercel for example
Step 5
Then in your code
(auth)/auth/callback/oauth
magnussentio commentedon Jul 11, 2024
So this was never resolved correct? I'm not the most code savy but I encounter this same issue using WeWeb.io, a no code frontend that integrates with Supabase and Supabase Auth. I'm building an app specific to the Twitter (X) community, however, during debugging, I couldn't even log in to my own app because I don't have an email associated with my Twitter account (lol right). For creators like me, who currently rely on no-code solutions to move quickly, would love to use Supabase because of how friendly the pricing is, compared to other platforms like Xano (which are also more difficult to implement in my opinion). So is there any movement on no-email twitter login or is this officially dead?
Silur commentedon Aug 16, 2024
30% of users on X do not have emails associated to their account.
OAuth being unusable on 30% of the target platform means a non-functioning faulty product, it is not an edge-case that can be safely ignored for 3 years @kiwicopple @joshenlim
hf commentedon Aug 24, 2024
Hey folks! I understand your frustration as exemplified by this:
The team agrees with this. However, removing the dependence on email addresses is slowly in progress and we expect to ramp up and finish it in the next period. I can go in to why it's so challenging on our end, but we've already resolved most of the biggest challenges so there's not much more to do to lift the restriction.
Thank you for being patient with us!
Sequoya42 commentedon Sep 21, 2024
@hf Any update on this?
Any ETA?
thank you
quantumdominik commentedon Sep 30, 2024
@hf any updates here? Need this feature bad.
Mumbo-Jumbo-3 commentedon Oct 27, 2024
@hf pls ser no require email
exitss commentedon Feb 19, 2025
@hf please stop forcing email.
matheuseabra commentedon Apr 20, 2025
Honestly this bug has been around for +4 years this is just ridiculous.