GitHub OAuth Returns error=email_not_found

Your GitHub OAuth implementation may return the error "email not found" when a user logs in with their GitHub account if their email address is set to private.

If the user has the option "Keep my email addresses private" checked, GitHub returns the null value for the email. As a result, your authentication flow breaks.

The user must uncheck the "Keep my email addresses private" option and select a public email. After that, the GitHub authentication should work correctly.

I didn't check whether there is a workaround without relying on the user to have a public email address. I'm using an auth library that doesn't allow me to change the underlying API, so this is the only option in my case.

Support this blog 🧡

If you like this content and it helped you, please consider supporting this blog. This helps me create more free content and keep this blog alive.

Become a supporter