Closed ocluf closed 8 months ago
@ocluf this is such a good catch. I had no idea that the public email on GitHub could be null. I made this PR #9 to fix the issue based on your feedback (thanks for providing the code snippets).
Could you please make a test and let me know if it works fine before I merge the PR?
Thanks.
Hey @JustinyAhin
I had already implemented it for my application with those code snippets and it worked for me. Had a quick look at the pull request and LGTM
Fixed by #9
When you use the github oauth flow
src/routes/api/oauth/github/callback/+server.ts
it currently fails when the user does not have a public emailaddress set in their github account. (githubUser.email
becomes null and it throws a 400)https://stackoverflow.com/questions/35373995/github-user-email-is-null-despite-useremail-scope
I ran into this during testing because I don't have a public email on my github, but it could be a footgun for developers who do and think everything is working fine.
The template should probably be adjusted to either:
['user:email']
scope ingithubAuthOptions
and then using theuser/emails
endpoint retrieve the email in case of a null.Example