auth icon indicating copy to clipboard operation
auth copied to clipboard

Facebook OAuth Error: Error getting user email from external provider

Open mliebold opened this issue 1 year ago • 10 comments

Bug report

Describe the bug

When setting up OAuth with Facebook Login I am getting the error "Error getting user email from external provider". I have seen this error posted several other times here, but I have not an actual solution.

  • I have the scope added and when checking permissions on the Facebook Graph API Explorer it shows that the email scope is granted. image
  • When I try to return the email in the Facebook Graph API Explorer using me?fields=id,name,email it does not return the email and tells me "The email field was not returned. This may be because the email was missing, invalid or hasn't been confirmed." image
  • The email scope states "The email permission allows your app to read a person's primary email address."

What I assume is happening is that my Facebook account is old and at some point, I deleted the original email and added my new one. Facebook is probably not setting this email as a "Primary Email" in the backend and there does not seem to be a way to do so manually on my end. It does not make sense why they would not return my email when I am using it to sign in to my Facebook account.

This issue seems to most likely be on the Facebook end and I submitted a support ticket with them. But, relying so heavily on the email return for the authentication seems to be a bit of a flaw. I would like to use Supabase as my backend service including for authentication, but it doesn't seem very reliable if any users that go to sign into my application will not be able to if they have changed their email at some point in the past.

Any additional information on if my assumption is correct, or if there is a way around this issue, besides using a different authentication service, would be great.

Thank you

To Reproduce

Don't think you will be able to reproduce it unless you have a Facebook account that has changed email addresses

mliebold avatar Oct 06 '24 18:10 mliebold

I think I am having the same issue, I more recently moved over to a new email for my barely used facebook account. While testing out Supabase auth for a project it keeps giving me the "Error getting user email from external provider".

AudunBeck avatar Nov 23 '24 17:11 AudunBeck

Same error here, can someone look into it?

Maybe you can find something useful here for a PR:

https://github.com/thebergamo/react-native-fbsdk-next/issues/521

likesebiii avatar Dec 12 '24 09:12 likesebiii

I am facing the same issue too

bibhuti9 avatar Jan 20 '25 20:01 bibhuti9

any update for this issue?

bibhuti9 avatar Jan 20 '25 20:01 bibhuti9

I've found that this usually happens when a user has more than one email associated with their Facebook profile.

You can have them remove the old email addresses here:

https://accountscenter.facebook.com/personal_info

thealishakeri avatar Feb 10 '25 22:02 thealishakeri

Is there any update for this issue?

thealishakeri avatar Mar 13 '25 21:03 thealishakeri

Another cause of "Error getting user email from external provider" is when the user denies email address permission during Facebook OAuth flow, as illustrated below:

Image

This is a problem because there is no easy way to recover from this, for the following 2 reasons:

  • If the user changes their mind, you have to redirect them to https://www.facebook.com/settings/applications/app_details/?app_id=${FACEBOOK_APP_ID} while asking them to remove your app from their settings and try again
  • The exact parameters received by the callback URI from the Supabase backend are:
error = "server_error"
error_code = "unexpected_failure"
error_description = "Error getting user email from external provider"

so you are expected to parse "error_description" in order to provide proper instructions, which is bit of an anti-pattern.

masda70 avatar Apr 21 '25 11:04 masda70

Image I’ve figured out how to fix this Facebook bug. Go to https://www.facebook.com/settings/?tab=notifications and at the bottom of the page, make sure to check the box under Where you receive notifications -> Email -> Primary email address. After that, retrieving the email via OAuth will work correctly.

horsky avatar Oct 15 '25 13:10 horsky

thanks @horsky that fixes the issue!

@horsky great solution brother!

lundrimiljazi avatar Nov 27 '25 10:11 lundrimiljazi