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

providers/kakao

内置 Kakao 集成。

KakaoProfile

https://developers.kakao.com/docs/latest/ko/kakaologin/rest-api#req-user-info 类型来自:https://gist.github.com/ziponia/cdce1ebd88f979b2a6f3f53416b56a77

扩展

属性

connected_at?

optional connected_at: string;

has_signed_up?

optional has_signed_up: boolean;

id

id: number;

kakao_account?

optional kakao_account: {
  age_range: AgeRange;
  age_range_needs_agreement: boolean;
  birthday: string;
  birthday_needs_agreement: boolean;
  birthday_type: Birthday;
  birthyear: string;
  birthyear_needs_agreement: boolean;
  ci: string;
  ci_authenticated_at: string;
  ci_needs_agreement: boolean;
  email: string;
  email_needs_agreement: boolean;
  gender: Gender;
  gender_needs_agreement: boolean;
  is_email_valid: boolean;
  is_email_verified: boolean;
  name: string;
  name_needs_agreement: boolean;
  phone_number: string;
  phone_number_needs_agreement: boolean;
  profile: {
     is_default_image: boolean;
     nickname: string;
     profile_image_url: string;
     thumbnail_image_url: string;
  };
  profile_image_needs_agreement: boolean;
  profile_needs_agreement: boolean;
  profile_nickname_needs_agreement: boolean;
};
age_range?
optional age_range: AgeRange;
age_range_needs_agreement?
optional age_range_needs_agreement: boolean;
birthday?
optional birthday: string;
birthday_needs_agreement?
optional birthday_needs_agreement: boolean;
birthday_type?
optional birthday_type: Birthday;
birthyear?
optional birthyear: string;
birthyear_needs_agreement?
optional birthyear_needs_agreement: boolean;
ci?
optional ci: string;
ci_authenticated_at?
optional ci_authenticated_at: string;
ci_needs_agreement?
optional ci_needs_agreement: boolean;
email?
optional email: string;
email_needs_agreement?
optional email_needs_agreement: boolean;
gender?
optional gender: Gender;
gender_needs_agreement?
optional gender_needs_agreement: boolean;
is_email_valid?
optional is_email_valid: boolean;
is_email_verified?
optional is_email_verified: boolean;
name?
optional name: string;
name_needs_agreement?
optional name_needs_agreement: boolean;
phone_number?
optional phone_number: string;
phone_number_needs_agreement?
optional phone_number_needs_agreement: boolean;
profile?
optional profile: {
  is_default_image: boolean;
  nickname: string;
  profile_image_url: string;
  thumbnail_image_url: string;
};
profile.is_default_image?
optional is_default_image: boolean;
profile.nickname?
optional nickname: string;
profile.profile_image_url?
optional profile_image_url: string;
profile.thumbnail_image_url?
optional thumbnail_image_url: string;
profile_image_needs_agreement?
optional profile_image_needs_agreement: boolean;
profile_needs_agreement?
optional profile_needs_agreement: boolean;
profile_nickname_needs_agreement?
optional profile_nickname_needs_agreement: boolean;

properties?

optional properties: {
  id: string;
  msg_blocked: boolean;
  nickname: string;
  profile_image: string;
  registered_at: string;
  status: string;
  thumbnail_image: string;
};
id?
optional id: string;
msg_blocked?
optional msg_blocked: boolean;
nickname?
optional nickname: string;
profile_image?
optional profile_image: string;
registered_at?
optional registered_at: string;
status?
optional status: string;
thumbnail_image?
optional thumbnail_image: string;

synched_at?

optional synched_at: string;

AgeRange

type AgeRange: 
  | "1-9"
  | "10-14"
  | "15-19"
  | "20-29"
  | "30-39"
  | "40-49"
  | "50-59"
  | "60-69"
  | "70-79"
  | "80-89"
  | "90-";

Birthday

type Birthday: "SOLAR" | "LUNAR";

日期时间

type DateTime: string;

性别

type Gender: "female" | "male";

默认()

default<P>(options): OAuthConfig<P>

在您的页面中添加 Kakao 登录。

设置

回调 URL

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

配置

import { Auth } from "@auth/core"
import Kakao from "@auth/core/providers/kakao"
 
const request = new Request(origin)
const response = await Auth(request, {
  providers: [
    Kakao({ clientId: KAKAO_CLIENT_ID, clientSecret: KAKAO_CLIENT_SECRET }),
  ],
})

资源

配置

https://developers.kakao.com/console/app 创建一个提供商和一个 Kakao 应用程序。在 Kakao 登录下的应用程序设置中,激活 Web 应用程序,更改同意项目并配置回调 URL。

备注

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

创建凭据时使用的“授权重定向 URI”必须包含您的完整域名,并以回调路径结尾。例如;

스크린샷 2023-11-28 오후 9 27 41

  • 用于生产:https://{YOUR_DOMAIN}/api/auth/callback/kakao
  • 用于开发:https://127.0.0.1:3000/api/auth/callback/kakao
💡

Kakao 提供商附带一个 默认配置。要覆盖您的用例的默认值,请查看 自定义内置 OAuth 提供商

💡

Kakao 的客户端密钥位于 **摘要(韩语为 요약정보)选项卡的应用程序密钥字段**(我的应用程序 > 应用程序设置 > 摘要)

스크린샷 2023-11-28 오후 9 47 17

Kakao 的 clientSecret 密钥位于 **安全(韩语为 보안)选项卡的应用程序密钥字段**(我的应用程序 > 产品设置 > Kakao 登录 > 安全)

스크린샷 2023-11-28 오후 9 38 25

💡

Kakao 开发者控制台中有一个按钮,位于右上角,可以将语言从韩语切换到英语。

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

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

类型参数

类型参数
P 扩展 KakaoProfile

参数

参数类型
optionsOAuthUserConfig<P>

返回

OAuthConfig<P>

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