mirror of
https://github.com/better-auth/better-auth.git
synced 2026-10-19 11:24:57 -05:00
fix(kakao): use comma-separated consent scopes
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user