[GH-ISSUE #3100] ERROR: Provider did not return email (GITHUB APP) #18104

Closed
opened 2026-04-15 16:28:41 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @0xCodeMaieutics on GitHub (Jun 20, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/3100

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Ex:

  1. Add social provider config to betterAuth with GitHub clientId and clientSecret
  2. Create an auth client
  3. Sign in with social and specify github as a provider

Current vs. Expected behavior

current: Fails with:

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

after signing in with Github using keys of Github App.

expected: it shouldn't fail or there should be a config to make email saving optional. Social providers shouldn't be forced to return email necessarily.

What version of Better Auth are you using?

1.2.8

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 22.13.0
  npm: 10.9.2
  Yarn: 1.22.22
  pnpm: 9.4.0
Relevant Packages:
  next: 15.3.0
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.8.2
  better-auth: 1.2.8
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Client, Backend

Auth config (if applicable)

export const auth = betterAuth({
  appName: "",
  database: prismaAdapter(prisma, {
    provider: "postgresql",
  }),
  socialProviders: {
    github: {
      clientId: env.GITHUB_CLIENT_ID,
      clientSecret: env.GITHUB_CLIENT_SECRET,
      scope: ["user", "user:email"],
    },
  },
  onAPIError: {
    throw: true,
    onError: (error, ctx) => {
      console.error("Auth error:", error);
    },
    errorURL: "/auth/error",
  },
});

Additional context

Full error log:

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

It does not help to specify user or user:email in the scope as signing in with Github App does not return information about user's email.

Originally created by @0xCodeMaieutics on GitHub (Jun 20, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/3100 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Ex: 1. Add social provider config to `betterAuth` with GitHub clientId and clientSecret 2. Create an auth client 3. Sign in with social and specify `github` as a provider ### Current vs. Expected behavior **current:** Fails with: ``` ERROR [Better Auth]: Provider did not return email. This could be due to misconfiguration in the provider settings. ``` after signing in with Github using keys of Github App. **expected:** it shouldn't fail or there should be a config to make email saving optional. Social providers shouldn't be forced to return `email` necessarily. ### What version of Better Auth are you using? 1.2.8 ### Provide environment information ```bash Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6000 Available memory (MB): 16384 Available CPU cores: 10 Binaries: Node: 22.13.0 npm: 10.9.2 Yarn: 1.22.22 pnpm: 9.4.0 Relevant Packages: next: 15.3.0 eslint-config-next: N/A react: 19.1.0 react-dom: 19.1.0 typescript: 5.8.2 better-auth: 1.2.8 Next.js Config: output: N/A ``` ### Which area(s) are affected? (Select all that apply) Client, Backend ### Auth config (if applicable) ```typescript export const auth = betterAuth({ appName: "", database: prismaAdapter(prisma, { provider: "postgresql", }), socialProviders: { github: { clientId: env.GITHUB_CLIENT_ID, clientSecret: env.GITHUB_CLIENT_SECRET, scope: ["user", "user:email"], }, }, onAPIError: { throw: true, onError: (error, ctx) => { console.error("Auth error:", error); }, errorURL: "/auth/error", }, }); ``` ### Additional context Full error log: ``` ERROR [Better Auth]: Provider did not return email. This could be due to misconfiguration in the provider settings. ``` It does not help to specify `user` or `user:email` in the scope as signing in with Github App does not return information about user's `email`.
GiteaMirror added the locked label 2026-04-15 16:28:41 -05:00
Author
Owner

@0xCodeMaieutics commented on GitHub (Jun 20, 2025):

My fault, I didn't read the docs properly.

This solved it for me:

  • After creating your app, go to Permissions and Events > Account Permissions > Email Addresses and select "Read-Only"
<!-- gh-comment-id:2991693612 --> @0xCodeMaieutics commented on GitHub (Jun 20, 2025): My fault, I didn't read the docs properly. This solved it for me: - After creating your app, go to *Permissions and Events* > *Account Permissions* > *Email Addresses* and select "Read-Only"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#18104