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.
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.
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. |
Native app services can not use the redirect method.
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.
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
false
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.
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.
1. Get authorization codeisKakaoTalkInstalled()
to check if launching Kakao Talk is available.true
is returned, use Login with Kakao Talk: Web.false
, use Login with Kakao Account: Web.The service must implement the user's login process to the service. This document provides a guideline to implement the login process.
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>
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 |
Call loginWithKakaoTalk()
. Flutter SDK launches the Kakao Talk application and prompts the Consent screen asking for consent.
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.
// Login with Kakao Talk
try {
OAuthToken token = await UserApi.instance.loginWithKakaoTalk();
print('Login succeeds. ${token.accessToken}');
} catch (e) {
print('Login fails. $e')
}
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.
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.
// Login with Kakao Account
try {
OAuthToken token = await UserApi.instance.loginWithKakaoAccount();
print('Login succeeds. ${token.accessToken}');
} catch (e) {
print('Login fails. $e')
}
Call authorizeWithTalk()
. Flutter SDK launches Kakao Talk and displays the Kakao Login consent screen.
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.
try {
await AuthCodeClient.instance.authorizeWithTalk(
redirectUri: '${REDIRECT_URI}',
);
} catch (error) {
print('Failed to login $error');
}
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.
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.
try {
await AuthCodeClient.instance.authorize(
redirectUri: '${REDIRECT_URI}',
);
} catch (error) {
print('Login failed. $error');
}
To store the tokens issued from the Kakao authorization server into the token manager of the Flutter SDK, call the setToken()
method.
// 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);
Include two logics below when implementing Kakao Login with Flutter SDK.
isKakaoTalkInstalled()
to check whether Kakao Talk is available.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 (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');
}
}
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')
}
}
// 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.
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');
}
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')
}
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')
}
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');
}
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');
}
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.
Call hasToken()
.
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.
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')
}
}
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.
Call logout()
.
Regardless of the result of the logout request, the Flutter SDK deletes the access token and refresh token so that the login session expires.
// Logout
try {
await UserApi.instance.logout();
print('Logout succeeds. Tokens are deleted from SDK.');
} catch (e) {
print('Logout fails. Tokens are deleted from SDK.')
}
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.
Call unlink()
.
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.
/// Unlink current user from the app.
try {
await UserApi.instance.unlink();
print('Unlink succeeds. Tokens are deleted from SDK.');
} catch (e) {
print('Unlink fails.')
}
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.
Call accessTokenInfo()
.
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:
// 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.')
}
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.
Call me()
.
me()
returns the user information through the User
class.
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');
}
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].
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'}
.
To check if the user information is successfully updated under the designated property keys, call the Retrieving user information API.
// 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')
}
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 |
Prompts the shipping address picker to allow users to select a shipping address and returns the selected shipping address ID.
Call selectShippingAddresses()
.
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.
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');
}
Retrieves shipping addresses saved in the user's Kakao Account.
Call shippingAddresses()
.
Specify the address ID to the addressId
parameter.
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.
// 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');
}
}
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.
Call scopes()
.
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.
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')
}
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')
}
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
.
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.
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.
// 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')
}
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 | - |
This API is only allowed for the service that adopted Kakao Sync.
Checks the service terms that a user has consented to.
Call serviceTerms()
.
serviceTerms()
returns the UserServiceTerms
object.
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 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.
Call revokeServiceTerms()
. Specify the tags of the service terms you want to revoke consent for in tags
.
revokeServiceTerms()
returns the UserRevokedServiceTerms
object.
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);
}
Reference | App setting |
---|---|
signup() |
Install Initialize |
Permission | Prerequisite | Kakao Login | User consent |
---|---|---|---|
Required | Register platforms Activate Kakao Login |
Required | - |
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');
}
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.
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.
// Requesting signup
try {
await UserApi.instance.signup();
print('signup succeeds.');
} catch (error) {
print('signup fails. $error')
}
If you want to store the user's information when the user is linked to your app, pass properties
.