페이지 이동경로
  • Docs>
  • Kakao Login>
  • Flutter

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.

API Recommended environment Implementation method Description
Login with Kakao Talk
(Recommended)
Native app service Default method:
Request authorization code and tokens with one API on the service client.
Launches Kakao Talk to authenticate users.
Login with Kakao Account Opens a pop-up page to log in with a Kakao Account on the default browser.
Login with Kakao Talk: Web
(Recommended)
Web service Redirect 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: Web Moves to the page to log in with a Kakao Account from the service page.
Caution

Native app services can not use the redirect method.

Note

The Kakao Account login page may not be properly displayed on the web browser or web view. But when implemented using the Redirect implement method, the Kakao Account login page can be opened from the service page without pop-ups.

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.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>

Login

Basic information
Reference App setting
isKakaoTalkInstalled()
loginWithKakaoTalk()
loginWithKakaoAccount()
authorizeWithTalk()
authorize()
setToken()
OAuthToken
KakaoException
Install
Initialize
project-setting
Permission Prerequisite Kakao Login User consent
- Register platforms
Activate Kakao Login
Manage consent items
Advanced: Activate OpenID Connect(Optional)
Set Simple Signup(for Kakao Sync)
Required Required:
Required consent item

Login with Kakao Talk

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 (e) {
  print('Login fails. $e')
}

Login with Kakao Account

Request

Call loginWithKakaoAccount(). Flutter SDK opens a pop-up 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 (e) {
  print('Login fails. $e')
}

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');
}

Set tokens

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.

기본
Redirect
// 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 (e) {
    print('Login failed. $e');

    // 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 (e is PlatformException && e.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 (e) {
      print('Login failed. $e');
    }
  }
} else {
  try {
    OAuthToken token = await UserApi.instance.loginWithKakaoAccount();
    print('Login succeeded. ${token.accessToken}');
  } catch (e) {
    print('Login failed. $e');
  }
}
bool talkInstalled = await isKakaoTalkInstalled();

if (talkInstalled) {
  // Login with Kakao Talk. If Kakao Talk is not installed, the download page is open.
  try {
    await AuthCodeClient.instance.authorizeWithTalk(
      redirectUri: '${REDIRECT_URI}',
    );
  } catch (error) {
    print('Login with Kakao Talk fails $error');
  }
} else {
  // Login with Kakao Account
  try {
    await AuthCodeClient.instance.authorize(
      redirectUri: '${REDIRECT_URI}',
    );
  } catch (error) {
    print('Login with Kakao Account fails. $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.

Mobile app
Web app
/// 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')
  }
}
// Request additional consent to the required scopes (Email and gender in this code snippet). 
try {
  await AuthCodeClient.instance.authorizeWithNewScopes(
    scopes: [account_email, gender],
    redirectUri: '${REDIRECT_URI}',
  );
} catch (error) {
  print('Failed to retrieve user information. $error');
}

// Implement a logic to request the new access token and store the new token.

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

Note

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 [My Application] > [Kakao Login] > [Simple Signup] 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');
}

Request reauthentication

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 (e) {
    print('Login fails. $e')
  }

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 (e) {
    print('Login fails. $e')
  }

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
Reference App setting
accessTokenInfo()
AccessTokenInfo
Install
Initialize
Permission Prerequisite Kakao Login User consent
- Register platforms
Activate Kakao Login
Required -

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 (e) {
      print('Login fails. $e')
    }
  }
} else {
  print('There is no token.');
    try {
      OAuthToken token = await UserApi.instance.loginWithKakaoAccount();
      print('Login succeeds. ${token.accessToken}');
    } catch (e) {
      print('Login fails. $e')
    }
}

Logout

Basic information
Reference App setting
logout() Install
Initialize
Permission Prerequisite Kakao Login User consent
- Register platforms
Activate Kakao Login
Required -

Makes the issued access token and the refresh token expire.

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 deleted from SDK.');
} catch (e) {
  print('Logout fails. Tokens are deleted from SDK.')
}

Unlink

Basic information
Reference App setting
unlink()
UserIdResponse
Install
Initialize
Permission Prerequisite Kakao Login User consent
- Register platforms
Activate Kakao Login
Required -

Unlinks the user and the service app.

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 deleted from SDK.');
} catch (e) {
  print('Unlink fails.')
}

Retrieve token information

Basic information
Reference App setting
accessTokenInfo()
AccessTokenInfo
Install
Initialize
Permission Prerequisite Kakao Login User consent
- Register platforms
Activate Kakao Login
Required -

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.')
}

Retrieve user information

Basic information
Reference App setting
me()
User
Install
Initialize
Permission Prerequisite Kakao Login User consent
- Register platforms
Activate Kakao Login
Manage consent items
Required Required:
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 information

Basic information
Reference App setting
updateProfile()
User.properties
Install
Initialize
Permission Prerequisite Kakao Login User consent
- Register platforms
Activate Kakao Login
Manage user properties
Required -

Stores or updates additional user information on the Kakao platform to use in a service, which is called 'User properties'. You can store or update additional user information into the user property keys that you designated in [My Application] > [Kakao Login] > [User Properties].

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 [My Application] > [Kakao Login] > [User Properties] in Kakao Developers.

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')
}

Shipping address

Basic information
Reference App setting
selectShippingAddresses()
shippingAddresses()
UserShippingAddresses
Install
Initialize
Set Custom URL scheme
Permission Prerequisite Kakao Login User consent
Required Register platforms
Activate Kakao Login
Manage consent items
Required Required:
Shipping information

Select shipping address

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

Request

Call selectShippingAddresses().

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 Troubleshooting for the error cause.

Sample

try {
  final addressId = await UserApi.instance.selectShippingAddresses();
  final userShippingAddresses = await UserApi.instance.shippingAddresses(addressId: addressId);

  Log.i(context, tag,
      'Success\nService user ID: ${userShippingAddresses.userId}\n배송지: ${userShippingAddresses.shippingAddresses?.join('\n')}');
} catch(e) {
  Log.e(context, tag, 'Failed to retrieve the shipping address $e');
}

Retrieve shipping address

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 Troubleshooting 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 [My Application] > [Kakao Login] > [Consent items]');
} 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
Reference App setting
scopes()
ScopeInfo
Install
Initialize
Permission Prerequisite Kakao Login User consent
- Register platforms
Activate Kakao Login
Manage consent items
Required -

Retrieves the detailed information of the scopes (consent items) that a user has agreed to. You can check all scopes set in [My Application] > [Kakao Login] > [Consent Items] 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 [My Application] > [Kakao Login] > [Consent Items] 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
Reference App setting
revokeScopes()
ScopeInfo
Install
Initialize
Permission Prerequisite Kakao Login User consent
- Register platforms
Activate Kakao Login
Manage consent items
Required -

Revokes the scope that a user has agreed to. You can only revoke the scope with revocable is true.

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: scopes);
  print('Succeeded in revoking consent.\n Scopes being used or agreed: ${scopeInfo.scopes}');
} catch (error) {
  print('Failed to revoke consent. $error')
}

Service terms

Basic information
Reference App setting
serviceTerms()
revokeServiceTerms()
UserRevokedServiceTerms
RevokedServiceTerms
UserServiceTerms
ServiceTerms
Install
Initialize
Permission Prerequisite Kakao Login User consent
Required: Kakao Sync Register platforms
Activate Kakao Login
Manage consent items
Set Simple Signup
Required -
Note

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

Retrieve consent details for service terms

Checks the service terms that a user has consented to.

Request

Call serviceTerms().

Response

serviceTerms() returns the UserServiceTerms object.

Sample

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

Revoke consent for service terms

Revoke a service terms that a specific user has agreed to. Only service terms with a revocable value of true in the Retrieving consent details for service terms response can be revoked.

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 {
  UserRevokedServiceTerms userRevokedServiceTerms =
      await UserApi.instance.revokeServiceTerms(tags: ['test_tag1', 'test_tag2']);
  Log.i(context, tag,
      'Success in revoking consent for service terms\nService user ID: ${userRevokedServiceTerms.id}\nRevoked service terms: \n${userRevokedServiceTerms.revokedServiceTerms?.join('\n')}');
} catch (e) {
  Log.e(context, tag, 'Failed to revoke consent for service terms', e);
}

Advanced: Manual signup

Basic information
Reference App setting
signup() Install
Initialize
Permission Prerequisite Kakao Login User consent
Required Register platforms
Activate Kakao Login
Required -
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 value Status Action
true The user is already linked with your app. You do not need to call the Manual signup API.
false The user is not linked with your app. You must call signup() to link the user with your app manually.
null Your 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.