跳至内容
从 NextAuth.js v4 迁移?阅读 我们的迁移指南.

providers/github

内置 GitHub 集成。

GitHubEmail

属性

email

email: string;

primary

primary: boolean;

verified

verified: boolean;

visibility

visibility: "private" | "public";

GitHubProfile

参见

获取已认证的用户

可索引

[claim: string]: unknown

属性

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>

将 GitHub 登录添加到您的页面并向 GitHub API 发送请求。

设置

回调 URL

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

配置

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 }),
  ],
})

资源

注意

默认情况下,Auth.js 假设 GitHub 提供商基于 OAuth 2 规范。

💡

GitHub 提供程序带有 默认配置。要覆盖您的用例的默认值,请查看 自定义内置 OAuth 提供程序.

免责声明 如果您认为在默认配置中发现错误,您可以 打开问题.

Auth.js 严格遵守规范,无法对提供程序的任何偏离规范的行为负责。您可以打开问题,但如果问题是非规范合规性,我们可能不会寻求解决方案。您可以在 讨论 中寻求更多帮助。

参数

参数类型
配置OAuthUserConfig<GitHubProfile> & { enterprise: { baseUrl: string; }; }

返回值

OAuthConfig<GitHubProfile>

Auth.js © Balázs Orbán 和团队 -2024