跳到內容
從 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";

DateTime

type DateTime: string;

Gender

type Gender: "female" | "male";

default()

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

將 Kakao 登入新增至您的頁面。

設定

回調網址

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 登入底下啟用網頁應用程式、變更同意項目並設定回調 URL。

注意事項

預設情況下,Auth.js 假設 Kakao 供應商基於 OAuth 2 規格。

建立憑證時使用的「授權重新導向 URI」必須包含您的完整網域,並以回調路徑結尾。例如:

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

  • 在生產環境:https://{您的網域}/api/auth/callback/kakao
  • 在開發環境:https://127.0.0.1:3000/api/auth/callback/kakao
💡

Kakao 供應商帶有預設設定。要覆寫您使用案例的預設值,請查看自訂內建 OAuth 供應商

💡

Kakao 的客戶端金鑰在 摘要(韓文寫作 요약정보)標籤的應用程式金鑰欄位中(我的應用程式 > 應用程式設定 > 摘要)。

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

Kakao 的客戶端密鑰在 安全(韓文寫作 보안)標籤的應用程式金鑰欄位中(我的應用程式 > 產品設定 > Kakao 登入 > 安全)。

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

💡

Kakao 開發者控制台的右上角有一個按鈕可以從韓文切換到英文。

免責聲明 如果您認為在預設設定中發現錯誤,您可以開啟一個問題

Auth.js 嚴格遵守規格,並且不對供應商偏離規格的行為負責。您可以開啟一個問題,但如果問題是不符合規格,我們可能不會尋求解決方案。您可以在討論區尋求更多協助。

類型參數

類型參數
P 擴展自 KakaoProfile

參數

參數類型
optionsOAuthUserConfig<P>

返回

OAuthConfig<P>

Auth.js © Balázs Orbán 和團隊 -2024