コンテンツへスキップ
NextAuth.js v4からの移行?こちらをご覧ください 移行ガイド.

providers/kakao

組み込みのKakao統合。

KakaoProfile

https://developers.kakao.com/docs/latest/ko/kakaologin/rest-api#req-user-info 型 from : 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;

プロパティ?

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ログインをページに追加します。

設定

コールバック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ログインの下にあるアプリの設定で、ウェブアプリを有効化し、同意項目を変更し、コールバックURLを設定します。

注意事項

デフォルトでは、Auth.jsはKakaoプロバイダーがOAuth 2仕様に基づいていると想定しています。

資格情報を生成する際に使用する「承認されたリダイレクトURI」には、完全なドメインを含め、コールバックパスで終わる必要があります。例:

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

  • 本番環境:https://{YOUR_DOMAIN}/api/auth/callback/kakao
  • 開発環境:http://localhost:3000/api/auth/callback/kakao
💡

Kakaoプロバイダーにはデフォルトの設定があります。ユースケースに合わせてデフォルト設定をオーバーライドするには、組み込みOAuthプロバイダーのカスタマイズをご覧ください。

💡

Kakaoのクライアントキーは、**概要(韓国語では「요약정보」と表記されています)タブのアプリキーフィールド**にあります(マイアプリケーション > アプリ設定 > 概要)。

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

KakaoのclientSecretキーは、**セキュリティ(韓国語では「보안」と表記されています)タブのアプリキーフィールド**にあります(マイアプリケーション > プロダクト設定 > Kakaoログイン > セキュリティ)。

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

💡

Kakao開発者コンソールには、右上にKRからENGに変更するボタンがあります。

免責事項 デフォルト設定のバグを見つけたと思われる場合は、issueを公開できます。

Auth.jsは仕様を厳密に遵守しており、プロバイダーによる仕様からのずれについて責任を負うことはできません。issueを公開できますが、問題が仕様への非準拠である場合、解決策を追求しない場合があります。Discussionsでより多くのヘルプを依頼できます。

型パラメーター

型パラメーター
P extends KakaoProfile

パラメーター

パラメーター
optionsOAuthUserConfig<P>

戻り値

OAuthConfig<P>

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