UNPKG

@auth/core

Version:

Authentication for the Web.

127 lines 4.4 kB
/** * <div class="provider" style={{backgroundColor: "#24292f", display: "flex", justifyContent: "space-between", color: "#fff", padding: 16}}> * <span>Built-in <b>GitHub</b> integration.</span> * <a href="https://github.com"> * <img style={{display: "block"}} src="https://authjs.dev/img/providers/github.svg" height="48" width="48"/> * </a> * </div> * * @module providers/github */ import type { OAuthConfig, OAuthUserConfig } from "./index.js"; export interface GitHubEmail { email: string; primary: boolean; verified: boolean; visibility: "public" | "private"; } /** @see [Get the authenticated user](https://docs.github.com/en/rest/users/users#get-the-authenticated-user) */ export interface GitHubProfile { login: string; id: number; node_id: string; avatar_url: string; gravatar_id: string | null; url: string; html_url: string; followers_url: string; following_url: string; gists_url: string; starred_url: string; subscriptions_url: string; organizations_url: string; repos_url: string; events_url: string; received_events_url: string; type: string; site_admin: boolean; name: string | null; company: string | null; blog: string | null; location: string | null; email: string | null; hireable: boolean | null; bio: string | null; twitter_username?: string | null; public_repos: number; public_gists: number; followers: number; following: number; created_at: string; updated_at: string; private_gists?: number; total_private_repos?: number; owned_private_repos?: number; disk_usage?: number; suspended_at?: string | null; collaborators?: number; two_factor_authentication: boolean; plan?: { collaborators: number; name: string; space: number; private_repos: number; }; [claim: string]: unknown; } /** * Add GitHub login to your page and make requests to [GitHub APIs](https://docs.github.com/en/rest). * * ### Setup * * #### Callback URL * ``` * https://example.com/api/auth/callback/github * ``` * * #### Configuration * ```ts * 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 * * - [GitHub - Creating an OAuth App](https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app) * - [GitHub - Authorizing OAuth Apps](https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps) * - [GitHub - Configure your GitHub OAuth Apps](https://github.com/settings/developers) * - [Learn more about OAuth](https://authjs.dev/concepts/oauth) * - [Source code](https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/providers/github.ts) * * ### Notes * * By default, Auth.js assumes that the GitHub provider is * based on the [OAuth 2](https://www.rfc-editor.org/rfc/rfc6749.html) specification. * * :::tip * * The GitHub provider comes with a [default configuration](https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/providers/github.ts). * To override the defaults for your use case, check out [customizing a built-in OAuth provider](https://authjs.dev/guides/configuring-oauth-providers). * * ::: * * :::info **Disclaimer** * * If you think you found a bug in the default configuration, you can [open an issue](https://authjs.dev/new/provider-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](https://authjs.dev/new/github-discussions). * * ::: */ export default function GitHub(config: OAuthUserConfig<GitHubProfile> & { /** Configuration for usage with [GitHub Enterprise Server](https://docs.github.com/en/enterprise-server/get-started). */ enterprise?: { /** The base URL of your GitHub Enterprise Server instance. */ baseUrl?: string; }; }): OAuthConfig<GitHubProfile>; //# sourceMappingURL=github.d.ts.map