apps/docs/content/guides/auth/social-login/auth-kakao.mdx
To enable Kakao Auth for your project, you need to set up a Kakao OAuth application and add the application credentials to your Supabase Dashboard.
Kakao OAuth consists of six broad steps:
REST API key - this serves as the client_id.Kakao Login Client Secret code - this serves as the client_secret.client id and client secret keys to your Supabase Project.This serves as the client_id when you make API calls to authenticate the user.
REST API key. This will become your client_id later.<$Partial path="social_provider_setup.mdx" variables={{ "provider": "Kakao" }} />
client_secret for your Supabase project.If you don't need an email address (or account_email isn't available for your app), you can omit account_email and enable Allow users without an email in the Supabase Kakao provider settings.
In the Kakao Developers Portal, the "account_email" consent item is only available for apps that are registered as "Biz App". To convert your app to a "Biz App", go to App Settings > App > General, and complete the required fields in the Business Information section.
</Admonition><$Partial path="social_provider_settings_supabase.mdx" variables={{ "provider": "Kakao" }} />
If you did not request account_email in Kakao, enable Allow users without an email in the Kakao provider settings.
<Tabs scrollable size="small" type="underlined" defaultActiveId="js" queryGroup="language"
<TabPanel id="js" label="JavaScript">
<$Partial path="create_client_snippet.mdx" />
When your user signs in, call signInWithOAuth() with kakao as the provider:
import { createClient } from '@supabase/supabase-js'
const supabase = createClient('<your-project-url>', '<sb_publishable_... or anon key>')
// ---cut---
async function signInWithKakao() {
const { data, error } = await supabase.auth.signInWithOAuth({
provider: 'kakao',
})
}
When your user signs in, call signInWithOAuth() with kakao as the provider:
Future<void> signInWithKakao() async {
await supabase.auth.signInWithOAuth(
OAuthProvider.kakao,
redirectTo: kIsWeb ? null : 'my.scheme://my-host', // Optionally set the redirect link to bring back the user via deeplink.
authScreenLaunchMode:
kIsWeb ? LaunchMode.platformDefault : LaunchMode.externalApplication, // Launch the auth screen in a new webview on mobile.
);
}
When your user signs in, call signInWith(Provider) with Kakao as the Provider:
suspend fun signInWithKakao() {
supabase.auth.signInWith(Kakao)
}
<$Partial path="oauth_pkce_flow.mdx" />
<Tabs scrollable size="small" type="underlined" defaultActiveId="js" queryGroup="language"
<TabPanel id="js" label="JavaScript">
When your user signs out, call signOut() to remove them from the browser session and any objects from localStorage:
async function signOut() {
const { error } = await supabase.auth.signOut()
}
When your user signs out, call signOut() to remove them from the browser session and any objects from localStorage:
Future<void> signOut() async {
await supabase.auth.signOut();
}
When your user signs out, call signOut() to remove them from the browser session and any objects from localStorage:
suspend fun signOut() {
supabase.auth.signOut()
}
Kakao Login JS SDK is an official Kakao SDK for authenticating Kakao users on websites.
Exchange the authorization code returned by Kakao API for an ID Token.
For example, this code shows a how to get ID Token:
const requestUrl = new URL(request.url);
const code = requestUrl.searchParams.get('code');
if (code) {
const res = await fetch('https://kauth.kakao.com/oauth/token', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
},
body: new URLSearchParams({
grant_type: 'authorization_code',
client_id: '<CLIENT_ID>',
redirect_uri: '<url>/api/auth/kakao/oidc',
code,
client_secret: '<CLIENT_SECRET>',
}),
});
const {id_token} = await res.json();
}
Use the ID Token to sign in:
const res = await auth.signInWithIdToken({
provider: 'kakao',
token: id_token,
});
openid to scope along with the scope values you wish to obtain consent for.