fix(kakao): use comma-separated consent scopes

This commit is contained in:
Taesu
2026-10-17 05:53:05 +09:00
parent 6c29428f75
commit 385e2ddb8f
3 changed files with 29 additions and 2 deletions
+1 -1
View File
@@ -2,4 +2,4 @@
"@better-auth/core": minor
---
Kakao profile callbacks now accept responses without account information. Profile mappings must handle an omitted `kakao_account`.
Kakao profile mappings now accept profiles without account information. Authorization requests separate consent scopes with commas as documented by Kakao.
@@ -1,4 +1,4 @@
import { assertType, it } from "vitest";
import { assertType, expect, it } from "vitest";
import type { KakaoProfile } from "./kakao";
/**
@@ -7,3 +7,29 @@ import type { KakaoProfile } from "./kakao";
it("accepts a Kakao profile without account information", () => {
assertType<KakaoProfile>({ id: 123 });
});
import { kakao } from "./kakao";
/** @see https://developers.kakao.com/docs/ko/kakaologin/rest-api#req-auth-code */
it("joins authorization scopes with commas", async () => {
const provider = kakao({ clientId: "app", scope: ["openid"] });
const url = await provider.createAuthorizationURL({
state: "state",
redirectURI: "https://example.com/callback",
codeVerifier: "",
scopes: ["gender"],
});
expect(url.searchParams.get("scope")).toBe(
"account_email,profile_image,profile_nickname,openid,gender",
);
const custom = await kakao({
clientId: "app",
disableDefaultScope: true,
scope: ["account_email", "gender"],
}).createAuthorizationURL({
state: "state",
redirectURI: "https://example.com/callback",
codeVerifier: "",
});
expect(custom.searchParams.get("scope")).toBe("account_email,gender");
});
@@ -118,6 +118,7 @@ export const kakao = (options: KakaoOptions) => {
options,
authorizationEndpoint: "https://kauth.kakao.com/oauth/authorize",
scopes: _scopes,
scopeJoiner: ",",
state,
redirectURI,
additionalParams,