본문 바로가기메인 메뉴 바로가기사이드 메뉴 바로가기

kakao developers

Related sites
  • Docs
  • Kakao Login
  • Flutter

사이드 메뉴

Kakao Map

Search

Kakao Login

Flutter

This document describes how to integrate Kakao Login APIs into your service with the Kakao SDK for Flutter.

To learn about each API in detail, refer to Concepts.

For a Kakao Login button, you can download the resources provided by Kakao or customize buttons according to your service user interface by referring to the Design Guide.

Before you begin

Project Setting

To use the Kakao Login API on the native app service, you must set the Custom URL Scheme. See how to set up a project by device environment below.

Select method

Implementation method

Flutter SDK supports two types of implementation methods for Kakao Login.

APISupported environmentImplementation methodDescription
Login with Kakao Talk
(Recommended)
Native app serviceDefault method:
Request authorization code and tokens with one API on the service client.
Launches Kakao Talk to authenticate users.
Login with Kakao AccountOpens a pop-up page to log in with a Kakao Account on the default browser.
Login with Kakao Talk: Web
(Recommended)
Web serviceRedirect method:
Request authorization code on the service client, and then request tokens on the service server.
Refer to Kakao Login process: Web.
Launches Kakao Talk to authenticate users.
Login with Kakao Account: WebMoves to the page to log in with a Kakao Account from the service page.
Caution

Native app services can not use the redirect method.

Recommendation

Login with Kakao Talk or Login with Kakao Talk: Web is highly recommended for a user environment supporting Kakao Talk. To check if launching Kakao Talk is available, use isKakaoTalkInstalled(). The results are below.

  • true
    • Requested by a native app on a mobile device, and Kakao Talk is installed.
    • Requested by a web browser or web view on a mobile device.
  • false
    • Requested by a native app on a mobile device, but Kakao Talk is not installed.
    • Not requested on a mobile device.

For the services that support multiple accounts or user environments that do not support Kakao Talk, Login with Kakao Account or Login with Kakao Account: Web is recommended.

Determine which authentication method to use for the user environment and service flows. Two authentication methods can be used both. Refer to each document.

Kakao Login process: Web

When using the Login with Kakao Talk: Web or Login with Kakao Account: Web for the redirect method, the service must request tokens from the service server to complete the Kakao Login process. The Kakao Login process using the redirect method is below.

Kakao Login process: Web

1. Get authorization code
  1. Request isKakaoTalkInstalled() to check if launching Kakao Talk is available.
  2. After requesting Login with Kakao Talk: Web, Kakao Talk is launched.
    • If Kakao Talk is not installed, the install page is displayed.
  3. Kakao Talk requests authentication to the Kakao authentication server.
  4. Kakao authentication server requests users authorization for the consent items.
    • The consent screen displays consent items that are set in the app.
  5. Users authorize required and desired consent items and select [Agree and Continue].
  6. Kakao authentication server passes the authorization code to the Redirect URI.
2. Get tokens
  1. Request tokens using the authorization code passed to the Redirect URI on the service server.
  2. Kakao authentication server issues tokens and returns them to the service server.
3. Service login
Caution

The service must implement the user's login process to the service. This document provides a guideline to implement the login process.

  • Request Retrieve user information using the access token on the service server. Map the user with the Service User ID in the response.
    • Retrieve user information can be requested on the service client after setting tokens.
  • Proceed with the login or sign-up process, depending on the mapping result.
  • After the required login process, finish the user's Kakao Login to the service.

Set Custom URL scheme

To use Select shipping address API, set a custom URL scheme in AndroidManifest.xml. Refer to the sample below.

<application>
<activity
android:name="com.kakao.sdk.flutter.auth.AppsHandlerActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Setting for the shipping address picker -->
<data android:scheme="kakao${YOUR_NATIVE_APP_KEY}" />
<data android:host="address" />
</intent-filter>
</activity>
</application>

Kakao Login

Basic information

Opens the Kakao Login page and the Consent screen to sign users in to your service with authentication information from Kakao Talk or Kakao Account.

Login with Kakao Talk

From Flutter SDK v2, the web login behavior changed and Login with Kakao Talk is not supported in web environments. For web services, use Login with Kakao Talk: Web.

Request

Call loginWithKakaoTalk(). Flutter SDK launches the Kakao Talk application and prompts the Consent screen asking for consent.

Response

When a user consents, Kakao identifies the user with the user's Kakao Account information linked to Kakao Talk, and then issues tokens. The Flutter SDK provides the issued tokens through the OAuthToken class.

The issued tokens are stored through the TokenManagerProvider class. The stored tokens are automatically added to the authorization header when calling the token-based APIs.

Sample

// Login with Kakao Talk
try {
OAuthToken token = await UserApi.instance.loginWithKakaoTalk();
print('Login succeeds. ${token.accessToken}');
} catch (error) {
print('Login fails. $error')
}

Login with Kakao Account

From Flutter SDK v2, the web login behavior changed and Login with Kakao Talk is not supported in web environments. For web services, use Login with Kakao Account: Web.

Request

Call loginWithKakaoAccount(). Flutter SDK opens a page to log in with a Kakao Account. Users can log in with an ID and password. After login, the Kakao Login consent screen is displayed.

Response

When a user consents, Kakao identifies the user through the user's Kakao Account cookie stored on the default web browser and then issues tokens through the OAuthToken class.

Sample

// Login with Kakao Account
try {
OAuthToken token = await UserApi.instance.loginWithKakaoAccount();
print('Login succeeds. ${token.accessToken}');
} catch (error) {
print('Login fails. $error')
}

Select Kakao Login method

Displays a login selection screen with Login with Kakao Talk and Login with Kakao Account buttons.

This feature is supported only on Android and iOS.

Request

Call loginWithKakao() to display a login selection screen with Login with Kakao Talk and Login with Kakao Account buttons.

The Flutter SDK provides the login selection screen. When calling loginWithKakao(), pass the light or dark mode setting for the login screen in LoginUiMode.

Pass the parameter settings used for logging in with Kakao Account in AccountLoginParams.

Response

The user logs in with Kakao Talk or Kakao Account depending on the selected login method. On successful login, tokens are returned. On failure, error information is provided.

Sample

try {
OAuthToken token = await UserApi.instance.loginWithKakao(context);
print('Login succeeded. ${token.accessToken}');
} catch (error) {
print('Login failed. $error');
}

Login with Kakao Talk: Web

Request

Call authorizeWithTalk(). Flutter SDK launches Kakao Talk and displays the Kakao Login consent screen.

Response

When the user agrees to all required consent items and selects [Agree and Continue], the authorization code is passed to the Redirect URI.

To get tokens, request tokens using the authorization code from the service server. Refer to Kakao Login process: Web.

Sample

try {
await AuthCodeClient.instance.authorizeWithTalk(
redirectUri: '${REDIRECT_URI}',
);
} catch (error) {
print('Failed to login $error');
}

Login with Kakao Account: Web

Request

Call authorize(). Flutter SDK opens the Kakao Account login page from the service page. Users can log in with an ID and password. After login, the Kakao Login consent screen is displayed.

Response

When the user agrees to all required consent items and selects [Agree and Continue], the authorization code is passed to the Redirect URI.

To get tokens, request tokens using the authorization code from the service server. Refer to Kakao Login process: Web.

Sample

try {
await AuthCodeClient.instance.authorize(
redirectUri: '${REDIRECT_URI}',
);
} catch (error) {
print('Login failed. $error');
}

Get token

When requesting Kakao Login via Login with Kakao Talk: Web or Login with Kakao Account: Web, the service server must request Get token using the authorization code through the REST API to issue a token.

After obtaining the token, the service server can call Retrieve user information using the access token to request the user information needed for signup and login. The access token can also be passed to the service client for Set token, allowing the service client to use the Kakao API with the Flutter SDK.

REST API key required

When making REST API requests such as Get token or Retrieve user information from the service server, the REST API key must be used.

Set token

Request

To store the tokens issued from the Kakao authorization server into the token manager of the Flutter SDK, call the setToken() method.

Sample

// Change the token type to the type that can be used in SDK.
var tokenResponse = AccessTokenResponse.fromJson(response);
var token = OAuthToken.fromResponse(tokenResponse);
// Store tokens.
TokenManagerProvider.instance.manager.setToken(token);

Kakao Login Sample

Include two logics below when implementing Kakao Login with Flutter SDK.

  1. Check if a token has been issued.
    • If an issued token exists, validate the access token to allow the user to skip the login process.
  2. Request isKakaoTalkInstalled() to check whether Kakao Talk is available.
    • If available, use Kakao Talk as the authentication method to allow users to log in without any IDs and passwords.
    • If not available, or Kakao Talk is not connected to a Kakao Account, use Kakao Account as the authentication method.

Refer to the sample below.

// Login combination sample + Detailed error handling callback
bool talkInstalled = await isKakaoTalkInstalled();
// If Kakao Talk has been installed, log in with Kakao Talk. Otherwise, log in with Kakao Account.
if (talkInstalled) {
try {
OAuthToken token = await UserApi.instance.loginWithKakaoTalk();
print('Login succeeded. ${token.accessToken}');
} catch (error) {
print('Login failed. $error');
// After installing Kakao Talk, if a user does not complete app permission and cancels Login with Kakao Talk, skip to log in with Kakao Account, considering that the user does not want to log in.
// You could implement other actions such as going back to the previous page.
if (error is PlatformException && error.code == 'CANCELED') {
return;
}
// If a user is not logged into Kakao Talk after installing Kakao Talk and allowing app permission, make the user log in with Kakao Account.
try {
OAuthToken token = await UserApi.instance.loginWithKakaoAccount();
print('Login succeeded. ${token.accessToken}');
} catch (error) {
print('Login failed. $error');
}
}
} else {
try {
OAuthToken token = await UserApi.instance.loginWithKakaoAccount();
print('Login succeeded. ${token.accessToken}');
} catch (error) {
print('Login failed. $error');
}
}

Additional features

Request additional consent

Call the loginWithNewScopes() method in the UserApi class by passing the scopes of user information you want to request additional consent as arguments.

Here is an example that checks which scopes are required to get additional consent by checking the value of ${FIELD_NAME}NeedsAgreement obtained through the Retrieving user information API.

/// Requesting additional consent
// You can request additional consent when the user attempts to use a service
// that requires specific user information and then obtain the user information as follows.
// * Caution: Consider the case that users refuse to consent to 'Optional consent' item
// to prevent a problem with the use of the service.
User user;
try {
user = await UserApi.instance.me();
} catch (error) {
print('Failed to retrieve user information. $error')
return;
}
// Check which scope are required to get additional consent.
List<String> scopes = [];
if (user.kakaoAccount?.emailNeedsAgreement == true) { scopes.add('account_email'); }
if (user.kakaoAccount?.birthdayNeedsAgreement == true) { scopes.add("birthday"); }
if (user.kakaoAccount?.birthyearNeedsAgreement == true) { scopes.add("birthyear");}
if (user.kakaoAccount?.legalNameNeedsAgreement == true) { scopes.add("legal_name"); }
if (user.kakaoAccount?.legalBirthDateNeedsAgreement == true) { scopes.add("legal_birth_date"); }
if (user.kakaoAccount?.legalGenderNeedsAgreement == true) { scopes.add("legal_gender"); }
if (user.kakaoAccount?.phoneNumberNeedsAgreement == true) { scopes.add("phone_number"); }
if (user.kakaoAccount?.profileNeedsAgreement == true) { scopes.add("profile"); }
if (user.kakaoAccount?.ageRangeNeedsAgreement == true) { scopes.add("age_range"); }
// If a user has not granted permission to provide user information that is needed for your service, request additional consent with the `loginWithNewScopes()` method.
if (scopes.length > 0) {
print('Need to obtain consent from user.');
// If OpenID Connect (OIDC) is enabled,
// - When "openid" is added to `scopes`, OIDC is applied.
// - When "openid" is not added to `scopes`, OAuth 2.0 is applied.
// To use OIDC, add "openid" to `scopes`.
// scopes.add("openid");
OAuthToken token;
try {
token = await UserApi.instance.loginWithNewScopes(scopes);
print('allowed scopes: ${token.scopes}');
} catch (error) {
print('Failed to obtain additional consent. $error')
return;
}
// Retrieve the user information after obtaining consent.
try {
User user = await UserApi.instance.me();
print('Succeeded in retrieving user information.'
'\nID: ${user.id}'
'\nEmail: ${user.kakaoAccount?.email}'
'\nNickname: ${user.kakaoAccount?.profile?.nickname}'
'\nProfileImage: ${user.kakaoAccount?.profile?.thumbnailImageUrl}');
} catch (error) {
print('Failed to retrieve user information. $error')
}
}

loginWithNewScopes() presents the Consent screen asking for consent to the requested scope. When a user chooses to provide the scope and selects [Accept and Continue] on the Consent screen, new tokens are issued, and the scope information is updated in the OAuthToken class.

On the other hand, authorizeWithNewScopes(), used for a web app, only returns an authorization code.

Get consent to desired service terms

Kakao Sync exclusive

This API is only allowed for the service that adopted Kakao Sync.

To request consent to specific scopes from a user, pass the list of service term tags through serviceTerms as an argument when you call loginWithKakaoTalk() or loginWithKakaoAccount().

If you do not add serviceTerms when requesting an authorization code, the general Kakao Login API proceeds. In this case, you cannot request consent to the desired service terms. Also, if a user has already consented to all required service terms, the user is logged in without the Consent screen prompted. For more details, refer to FAQ.

// Getting consent to desired service terms
// Designate tags for the service terms that you want to get consent
// among the service terms registered in [Kakao Login] > [Simple Signup] on the app management page in Kakao Developers.
List<String> serviceTerms = ['service'];
// Request login with Kakao Talk using the serviceTerms parameter (same for Login with Kakao Account)
try {
OAuthToken token = await UserApi.instance
.loginWithKakaoTalk(serviceTerms: serviceTerms);
print('Login success. ${token.accessToken}');
} catch (error) {
print('Login fail. $error');
}

Reauthentication login

You can request reauthentication regardless of a user's login status to enhance security. Set prompts to [Prompt.login] when you call loginWithKakaoAccount(). Then, the login screen is prompted even though a user has already been logged in on the same web browser on the device.

try {
OAuthToken token = await UserApi.instance
.loginWithKakaoAccount(prompts: [Prompt.login]);
print('Login succeeds. ${token.accessToken}');
} catch (error) {
print('Login fails. $error')
}

Log in after signing up for Kakao Account

You can request to prompt the Kakao Account sign-up page before Kakao Login. Set prompts to [Prompt.create] when you call loginWithKakaoAccount(). The Kakao Login consent screen is presented after signing up for Kakao Account.

try {
OAuthToken token = await UserApi.instance
.loginWithKakaoAccount(prompts: [Prompt.create]);
print('Login succeeds. ${token.accessToken}');
} catch (error) {
print('Login fails. $error')
}

Provide login hint

To fill in the ID automatically, use the loginHint parameter. The value of the loginHint parameter will be entered in the Kakao Account login page.

// Login with Kakao Account
List<String> loginHint = '${LOGIN_HINT}';
try {
OAuthToken token = await UserApi.instance
.loginWithKakaoAccount(loginHint: loginHint);
print('Login succeeds. ${token.accessToken}');
} catch (error) {
print('Login fails. $error');
}

Kakao Account easy login

To request Kakao Account easy login, set the prompt parameter to SelectAccount.

try {
OAuthToken token = await UserApi.instance
.loginWithKakaoAccount(prompts: [Prompt.select_account]);
print('Login succeeds. ${token.accessToken}');
} catch (error) {
print('Login fails. $error');
}

Check token presence

Basic information

Checks if a user has obtained an access token through Kakao Login.

Request

Call hasToken().

Response

If the user has a valid access token, hasToken() returns the token information through the AccessTokenInfo class. Then, you can call the token-based APIs with the user's access token.

If false is returned, it means that the token is not valid, so you cannot retrieve the token information. For this case, implement a process for the user to log in to obtain tokens and the error handling process.

Note that calling hasToken() to check the token presence does not ensure the user's login status.

Sample

if (await AuthApi.instance.hasToken()) {
try {
AccessTokenInfo tokenInfo = await UserApi.instance.accessTokenInfo();
print('Succeeded in validating token ${tokenInfo.id} ${tokenInfo.expiresIn}');
} catch (e) {
if (e is KakaoException && e.isInvalidTokenError()) {
print('Token has expired.')
} else {
print('Failed to retrieve token information.')
}
try {
// Log in with Kakao Account
OAuthToken token = await UserApi.instance.loginWithKakaoAccount();
print('Login succeeds. ${token.accessToken}');
} catch (error) {
print('Login fails. $error')
}
}
} else {
print('There is no token.');
try {
OAuthToken token = await UserApi.instance.loginWithKakaoAccount();
print('Login succeeds. ${token.accessToken}');
} catch (error) {
print('Login fails. $error')
}
}

Retrieve access token information

Basic information

Retrieves the validity period of the access and refresh tokens in seconds, app ID and service user ID.

Request

Call accessTokenInfo().

Response

If the request is successful, accessTokenInfo() returns the token information through the AccessTokenInfo class. If the access token expires, the access token is refreshed and new token information is returned.

You cannot trust the token information on the client side because it may expire if:

  • the user changes the Kakao Account password and invalidates tokens.
  • the user unlinks from your app.

Sample

// Retrieving token information
try {
AccessTokenInfo tokenInfo = await UserApi.instance.accessTokenInfo();
print('Succeeded in retrieving token information\nService user ID: ${tokenInfo.id}\nValidity period: ${tokenInfo.expiresIn} seconds');
} catch (e) {
print('Failed to retrieve token information.')
}

Logout

Basic information
ReferenceApp setting
logout()Install
Initialize

Logs out the user by revoking the tokens stored in the Flutter SDK.

After logout, you cannot call Kakao APIs with the user's information.

Request

Call logout().

Response

Regardless of the result of the logout request, the Flutter SDK deletes the access token and refresh token so that the login session expires.

Sample

// Logout
try {
await UserApi.instance.logout();
print('Logout succeeds. Tokens are revoked from SDK.');
} catch (e) {
print('Logout fails. Tokens are revoked from SDK.')
}

Unlink

Basic information

Withdraws the user's consent and revokes the issued access and refresh tokens.

For more details, see Unlink.

Request

Call unlink().

Response

If the request is successful, the session between an app and a user is disconnected, and the user is logged out as the issued access token and refresh token are deleted.

Sample

/// Unlink current user from the app.
try {
await UserApi.instance.unlink();
print('Unlink succeeds. Tokens are revoked from SDK.');
} catch (e) {
print('Unlink fails.')
}

Retrieve user information

Basic information
ReferenceApp setting
me()
User
Install
Initialize
PermissionPrerequisiteKakao LoginUser consent
-Platform key
Activate Kakao Login
Manage consent items
RequiredRequired:
All consent items to request user information

Retrieves Kakao Account information of a user who is logged into Kakao.

Request

Call me().

Response

me() returns the user information through the User class.

Sample

Here is an example of retrieving user information — Service user ID, email, nickname and profile thumbnail image URI.

// Retrieving user information
try {
User user = await UserApi.instance.me();
print('Succeeded in retrieving user information'
'\nService user ID: ${user.id}'
'\nEmail: ${user.kakaoAccount?.email}'
'\nNickname: ${user.kakaoAccount?.profile?.nickname}'
'\nProfile Thumbnail Image URI: ${user.kakaoAccount?.profile?.thumbnailImageUrl}');
} catch (e) {
print('Failed to retrieve user information');
}

Store user property

Basic information

Saves values to the user properties that you defined for your service.

You can only save values to user properties that have been registered in Kakao Developers. For details, refer to How to use.

Request

Call updateProfile(). You must pass the custom property keys and values that you want to upadate through properties in a key-value pair. For example, if you want to update a user's clothing size, set properties to {'clothing_size': 'small'}.

Response

To check if the user information is successfully updated under the designated property keys, call the Retrieving user information API.

Sample

// Storing or updating user's additional information
// Check the names of property keys that you can use in [Kakao Login] > [Advanced] > [User Properties] on the app management page.
try {
// Data to be updated
Map<String, String> properties = {'${CUSTOM_PROPERTY_KEY}': '${CUSTOM_PROPERTY_VALUE}'};
await UserApi.instance.updateProfile(properties);
print('Storing user information succeeds.');
} catch (error) {
print('Storing user information fails. $error')
}

Select shipping address

Basic information

Prompts the shipping address picker to allow users to select a shipping address and returns the selected shipping address ID.

Request

Call selectShippingAddress().

Response

This API returns an addressId for the selected shipping address. Request Retrieve shipping address with the addressId to get the detailed shipping address.

Refer to Error code for the error cause.

Sample

try {
final addressId = await UserApi.instance.selectShippingAddress();
final userShippingAddresses = await UserApi.instance.shippingAddresses(addressId: addressId);
print('Success\nService user ID: ${userShippingAddresses.userId}\nShipping addresses: ${userShippingAddresses.shippingAddresses?.join('\n')}');
} catch(error) {
print('Failed to retrieve the shipping address $error');
}

Retrieve shipping address

Basic information

Retrieves shipping addresses saved in the user's Kakao Account.

Request

Call shippingAddresses().

Specify the address ID to the addressId parameter.

Response

shippingAddresses() returns the UserShippingAddresses object. Refer to Error code for the error cause.

If not using Select shipping address API, the response may not include the shipping address when the user did not consent to the [Shipping information]. Refer to No shipping address in the response.

Sample

// Retrieve shipping address
UserShippingAddresses userShippingAddress;
try {
userShippingAddress = await UserApi.instance.shippingAddresses();
} catch (error) {
print('Failed to retrieve shipping address. $error');
return;
}
// Handling the response upon user agreement
if (userShippingAddress.shippingAddresses != null) {
print('Succeeded in retrieving shipping addresses'
'\nService user ID: ${userShippingAddress.userId}'
'\nShipping addresses: \n${userShippingAddress.shippingAddresses?.join('\n')}');
} else if (userShippingAddress.needsAgreement == false) {
print('User account does not have a shipping address'
'If required, select [Provision after collecting information] option in [Kakao Login] > [Consent items] on the app management page');
} else if (userShippingAddress.needsAgreement == true) {
print('You must obtain consent to providing shipping address from a user.');
// Scope ID for the shipping addresses
List<String> scopes = ['shipping_address'];
// Request consent to providing shipping addresses
OAuthToken token;
try {
token = await UserApi.instance.loginWithNewScopes(scopes);
print('allowed scopes: ${token.scopes}');
} catch (error) {
print('Failed to get consent to providing shipping address $error');
}
// Retry after getting user consent
try {
UserShippingAddresses userShippingAddresses =
await UserApi.instance.shippingAddresses();
print('Succeeded in retrieving shipping address'
'\nService user ID: ${userShippingAddresses.userId}'
'\n${userShippingAddresses.shippingAddresses?.join('\n')}');
} catch (error) {
print('Failed to retrieve shipping address $error');
}
}

Retrieve consent details

Basic information

Retrieves the detailed information of the scopes (consent items) that a user has agreed to.

You can check all scopes set in [Kakao Login] > [Consent Items] on the app management page and the details of the scopes. If a user has consented to the scope before, the scope is included in the response even though your app is currently not using the scope.

Request

Call scopes().

Response

If the request is successful, the API returns the details of the scopes that you enabled in [Kakao Login] > [Consent Items] on the app management page and that the user has consented through the scopeInfo object. Even though your app is currently not using the scope but if a user has consented to the scope before, the scope is included in the response.

Sample

try {
ScopeInfo scopeInfo = await UserApi.instance.scopes();
print('Succeeded in retrieving consent details succeeds.\n Scopes being used or agreed: ${scopeInfo.scopes}');
} catch (error) {
print('Failed to retrieve consent details. $error')
}

Additional feature

Check specific scopes

To retrieve the details of specific scopes only, you need to pass the scopes parameter as an argument when calling scopes().

// List of the scope IDs that you want to retrieve
List<String> scopes = ['account_email', 'friends'];
try {
ScopeInfo scopeInfo = await UserApi.instance.scopes(scopes: scopes);
print('Succeeded in retrieving consent details succeeds.\n Scopes being used or agreed: ${scopeInfo.scopes}');
} catch (error) {
print('Failed to retrieve consent details. $error')
}

Revoke consent

Basic information

Revokes the consent for certain scopes that the user has previously agreed to.

Revocable Scopes

Among the scope information retrieved by the Retrieve consent details API, only the scopes with the revocable value set to true can have their consent revoked.

If you request to revoke a scope that cannot be revoked, an error response is returned. Once a scope's consent has been revoked, the agreed value for that scope will be false in subsequent responses.

Request

Call revokeScopes(). You must pass the list of scope ID through the scopes parameter when calling revokeScopes(). If you request to revoke the scope that is not revocable, an error is returned.

Response

If the request is successful, the API returns the scopeInfo object that includes the changed details of each scope and whether a user has agreed to the scope.

Sample

// List of the scope IDs that you want to revoke
List<String> scopes = ['account_email', 'legal_birth_date', 'friends'];
try {
ScopeInfo scopeInfo = await UserApi.instance.revokeScopes(scopes);
print('Succeeded in revoking consent.\n Scopes being used or agreed: ${scopeInfo.scopes}');
} catch (error) {
print('Failed to revoke consent. $error')
}

Service terms

This section provides guidelines on how to use the service terms-related APIs.

Kakao Sync exclusive

This feature is only available for services that have adopted Kakao Sync.

Service terms precautions

  • User consent for service terms must be managed directly by the service in accordance with the Service terms management policy.
  • You can obtain consent for required service terms that the user has not agreed to or has revoked consent by the Get consent to desired service terms.
  • It is recommended to obtain consent for service terms not agreed to through Kakao Sync Simple Signup via a separate consent procedure.

Retrieve consent details for service terms

Basic information

Retrieves the service terms that a user has consented to.

Request

Call serviceTerms().

Response

serviceTerms() returns the UserServiceTerms object.

Sample

try {
final UserServiceTerms userServiceTerms =
await UserApi.instance.serviceTerms();
print('Success in retrieving consent details for service terms\nService user ID: ${userServiceTerms.id}\nService terms: \n${userServiceTerms.serviceTerms?.join('\n')}');
} catch (error) {
print('Failed to retrieve consent details for service terms $error');
}

Revoke consent for service terms

Basic information

Revokes a service terms that a specific user has agreed to.

Revocable service terms

You can revoke only service terms with the revocable (revocable) value of true in the response of the Retrieve consent details for service terms API. If the request succeeds, the response returns a list of service terms for which consent was revoked successfully. Service terms not agreed to by the user for which consent cannot be revoked are not included.

Request

Call revokeServiceTerms(). Specify the tags of the service terms you want to revoke consent for in tags.

Response

revokeServiceTerms() returns the UserRevokedServiceTerms object.

Sample

try {
final UserRevokedServiceTerms userRevokedServiceTerms =
await UserApi.instance.revokeServiceTerms(['test_tag1', 'test_tag2']);
print('Success in revoking consent for service terms\nService user ID: ${userRevokedServiceTerms.id}\nRevoked service terms: \n${userRevokedServiceTerms.revokedServiceTerms?.join('\n')}');
} catch (error) {
print('Failed to revoke consent for service terms $error');
}

Advanced: Manual signup

Basic information
ReferenceApp setting
signup()Install
Initialize

Manually links the app and user for apps that do not use Auto-link.

Note

The Manual signup API is only for the app with the Auto-link option disabled. Before using this API, check out when to use this API and the cautions in REST API.

The Manual signup API manually links a user with your app to complete signup when the Auto-link is disabled. To figure out if the currently logged-in user needs to be linked with your app, check the value of hasSignedUp by calling the Retrieving user information API and handle each case:

Return valueStatusAction
trueThe user is already linked with your app.You do not need to call the Manual signup API.
falseThe user is not linked with your app.You must call signup() to link the user with your app manually.
nullYour app is using the Auto-link feature.You do not need to call the Manual signup API.
// Checking if user is linked with your app by calling the Retrieving user information API.
try {
User user = await UserApi.instance.me();
print('Succeeded in retrieving user information.'
'\nService user ID: ${user.id}'
'\nLinked status:: ${user.hasSignedUp}');
} catch (error) {
print('Failed to retrieve user information. $error');
}

Request

If the return value of hasSignedUp is false and the user is ready to sign up, call the signup() method to complete the signup. You can also request to store user information needed for your service with the properties parameter.

Response

If the request is successful, the user's service ID is returned.

Because the user's linked status is not provided even when the request is successful, request the Retrieving user information API again and check the value of hasSignedUp to check the request result.

Sample

// Requesting signup
try {
await UserApi.instance.signup();
print('signup succeeds.');
} catch (error) {
print('signup fails. $error')
}

Additional feature

Update additional information

If you want to store the user's information when the user is linked to your app, pass properties.

Was this helpful?