GitHub
GitHub OAuth2. Pure OAuth2 — no PKCE, no id token.
Configure
python
from better_auth import BetterAuth, GitHub
auth = BetterAuth(
secret=...,
social_providers={
"github": GitHub(client_id="…", client_secret="…"),
},
)Or name-keyed (no import):
python
auth = BetterAuth(
secret=...,
social_providers={
"github": {"client_id": "…", "client_secret": "…"},
},
)Options
| Field | Type | Default | Notes |
|---|---|---|---|
client_id | str | list[str] | required | |
client_secret | str | required |
All shared ProviderConfig options apply.
Notes
- Default scopes:
read:user user:email. - Register
{base_url}{base_path}/callback/githubas the authorization callback URL in the GitHub OAuth app settings. GitHubis re-exported at the package root (from better_auth import GitHub).- User info takes two API calls:
GET /userfor the profile, thenGET /user/emailsto resolve the primary email and itsverifiedflag (the profile's public email can be absent or unverified). - Display name prefers
name, falling back tologin.