Skip to content
Migrating from NextAuth.js v4? Read our migration guide.
API reference
github

providers/github

Built-in GitHub integration.

GitHubEmail

Properties

email

email: string;

primary

primary: boolean;

verified

verified: boolean;

visibility

visibility: "public" | "private";

GitHubProfile

See

Get the authenticated user

Indexable

[claim: string]: unknown

Properties

avatar_url

avatar_url: string;

bio

bio: null | string;

blog

blog: null | string;

collaborators?

optional collaborators: number;

company

company: null | string;

created_at

created_at: string;

disk_usage?

optional disk_usage: number;

email

email: null | string;

events_url

events_url: string;

followers

followers: number;

followers_url

followers_url: string;

following

following: number;

following_url

following_url: string;

gists_url

gists_url: string;

gravatar_id

gravatar_id: null | string;

hireable

hireable: null | boolean;

html_url

html_url: string;

id

id: number;

location

location: null | string;

login

login: string;

name

name: null | string;

node_id

node_id: string;

organizations_url

organizations_url: string;

owned_private_repos?

optional owned_private_repos: number;

plan?

optional plan: {
  collaborators: number;
  name: string;
  private_repos: number;
  space: number;
};
collaborators
collaborators: number;
name
name: string;
private_repos
private_repos: number;
space
space: number;

private_gists?

optional private_gists: number;

public_gists

public_gists: number;

public_repos

public_repos: number;

received_events_url

received_events_url: string;

repos_url

repos_url: string;

site_admin

site_admin: boolean;

starred_url

starred_url: string;

subscriptions_url

subscriptions_url: string;

suspended_at?

optional suspended_at: null | string;

total_private_repos?

optional total_private_repos: number;

twitter_username?

optional twitter_username: null | string;

two_factor_authentication

two_factor_authentication: boolean;

type

type: string;

updated_at

updated_at: string;

url

url: string;

default()

default(config): OAuthConfig<GitHubProfile>

Add GitHub login to your page and make requests to GitHub APIs.

Setup

Callback URL

https://example.com/api/auth/callback/github

Configuration

import { Auth } from "@auth/core"
import GitHub from "@auth/core/providers/github"
 
const request = new Request(origin)
const response = await Auth(request, {
  providers: [
    GitHub({ clientId: GITHUB_CLIENT_ID, clientSecret: GITHUB_CLIENT_SECRET }),
  ],
})

Resources

Notes

By default, Auth.js assumes that the GitHub provider is based on the OAuth 2 specification.

💡

The GitHub provider comes with a default configuration. To override the defaults for your use case, check out customizing a built-in OAuth provider.

Disclaimer If you think you found a bug in the default configuration, you can open an issue.

Auth.js strictly adheres to the specification and it cannot take responsibility for any deviation from the spec by the provider. You can open an issue, but if the problem is non-compliance with the spec, we might not pursue a resolution. You can ask for more help in Discussions.

Parameters

ParameterType
configOAuthUserConfig<GitHubProfile> & { enterprise: { baseUrl: string; }; }

Returns

OAuthConfig<GitHubProfile>

Auth.js © Balázs Orbán and Team - 2024