페이지 이동경로
  • Docs>
  • Kakao Sync>
  • Get consent to desired terms

Kakao Sync

Get consent to desired terms

This API enables you to select the terms that users have not agreed to and get consent from them.

You can use this feature by adding the serviceTerms parameter when requesting authorization code for Kakao Login to request consent to specific terms regardless of whether the user has already signed up or not. 

You can use this API in the following cases:

  • If an app is used for multiple services
  • If a service adopting Kakao Sync adds a required term

If multiple services share an app to use Kakao Sync under the same membership system, the types of terms that each service requires may differ. In this case, you can register all kinds of terms needed for your services into your app and use the 'Getting consent to desired terms' API. Then, you can request users' consent to the terms that are required for each service when they log in the service. You can designate the terms needed to get consent with the tags that you have registered when adopting Kakao Sync.

Even though you use this API, the Consent screen is not prompted if:

  • A user has already agreed to all terms.
  • Terms of Service only include 'Optional terms'.

Thus, if you add a required term, first of all, call Checking the agreed terms API when logging in to check if what terms need consent, and call the 'Getting consent to the desired terms' API.

IMPORTANT: Specify tags when using additional parameter

When you use 'serviceTerms' when you request this API, you must specify the tags for the terms that the consent is required. If not, all terms are not displayed on the Consent screen. In this case, a user who has signed up through Simple Signup can log in without consenting to all terms of services. To prevent a problem, you should test this feature before applying it to your actual service.

Web

To use this API through the JavaScript SDK,

  • A user must be in a logged-in state.
  • You must install the JavaScript SDK.

Pass serviceTerms to the authorize() method as a parameter. Make sure to include all tags of the terms needed to get consent in a single String format by separating respective tags by comma(,).

Request

Parameter
Name Type Description Required
redirectUri String The URI used to get an authorization code. O
serviceTerms Sting Tags for the terms needed to get consent.
Tags should be in a single string format by separating respective tags by comma(,).
O

Response

The response is the same as the Getting authorization code. If successful, the Consent screen that only includes the designated terms is prompted during the login process.

Sample

Request
Kakao.Auth.authorize({
 redirectUri: 'https://developers.kakao.com/kakaoLogin.jsp',
 serviceTerms: 'tag1,tag2'
});
Response
HTTP/1.1 302 Found
Content-Length: 0
Location: ${REDIRECT_URI}?code=${AUTHORIZATION_CODE}

Android

Before you begin

To use this API,

  • Add the v2-user module that provides UserApiClient in the module-level build.gradle file by referring to Add modules.
How to implement

Add an additional parameter,serviceTerms, when you call loginWithKakaoTalk() or loginWithKakaoAccount() for Kakao Login.

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 terms. Also, if a user has already consented to all required terms, the user is logged in without the Consent screen prompted.

Name Type Description Required
serviceTerms List<String> Tags for the terms that are required to consent. O
Kotlin
RxKotlin
// Get consent to desired terms

// Designate tags for the terms that you want to get consent
// among the terms registered in [My Application] > [Simple Signup] in Kakao Developers. 
val serviceTerms = listOf("service")

// Request login with Kakao Talk using the serviceTerms parameter (same for Login with Kakao Account)
UserApiClient.instance.loginWithKakaoTalk(
    context = context,
    serviceTerms = serviceTerms
) { token, error ->
    if (error != null) {
        Log.e(TAG, "Login fail", error)
    }
    else if (token != null) {
        Log.i(TAG, "Login success ${token.accessToken}")
    }
}
var disposables = CompositeDisposable()

// Get consent to desired terms

// Designate tags for the terms that you want to get consent
// among the terms registered in [My Application] > [Simple Signup] in Kakao Developers. 
val serviceTerms = listOf("service")

// Request login with Kakao Talk using the serviceTerms parameter (same for Login with Kakao Account)
UserApiClient.rx.loginWithKakaoTalk(
    context = context,
    serviceTerms = serviceTerms
)
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe({ token ->
        Log.i(TAG, "Login success ${token.accessToken}")
    }, { error ->
        Log.e(TAG, "Login fail", error)
    })
    .addTo(disposables)

The response is the same as the Kakao Login.

Legacy Android

Declare parameters and set it to service_terms with the tags for the terms that you want to get consent from users. service_terms should be a string that includes all terms separated by comma(,).

You can pass parameters when calling Kakao Login. If successful, the Consent screen that only includes the designated terms is prompted during the login process.

    import com.kakao.auth.StringSet;

     // Declare parameters to use for the login request
    Map<String, String> parameters = new HashMap<>();

    // Add service_terms in a string format that includes all terms separated by ‘,’
    // ex) "tag1,tag2"
    parameters.put(StringSet.service_terms, "tag1,tag2");
    Session.getCurrentSession().open(AuthType.KAKAO_TALK, LoginActivity.this, parameters);

iOS

Before you begin

To use this API,

  • Add KakaoSDKAuth (Authentication and token management module) and KakaoSDKUser (Kakao Login module) in the Podfile by referring to Install SDK.
  • Add the import statements for Kakao Login.
Swift
RxSwift
import KakaoSDKAuth
import KakaoSDKUser
import KakaoSDKAuth
import RxKakaoSDKAuth

import KakaoSDKUser
import RxKakaoSDKUser
How to implement

Add an additional parameter,serviceTerms, when you call loginWithKakaoTalk() or loginWithKakaoAccount() for Kakao Login.

If you add serviceTerms when requesting an authorization code, the general Kakao Login API proceeds instead of Auto-login. In this case, you cannot request consent to the desired terms. Also, if a user has already consented to all required terms, the user is logged in without the Consent screen prompted.

Name Type Description Required
serviceTerms [String] Tags for the terms that are required to consent. O
Swift
RxSwift
// Add service_terms in a string format that includes all terms separated by ‘,’
// ex) "tag1,tag2"
let serviceTerms = ["tag1", "tag2"]

UserApi.shared.loginWithKakaoAccount(serviceTerms: serviceTerms, completion: {(oauthToken, error) in
if let error = error {
        print(error)
    }
    else {
        print("loginWithKakaoAccount(serviceTerms:) success.")        
        // Do something
        _ = oauthToken
    }
})
// Class member property
let disposeBag = DisposeBag()

// Add service_terms in a string format that includes all terms separated by ‘,’
//  ex) "tag1,tag2"
let serviceTerms = ["tag1", "tag2"]

UserApi.shared.rx.loginWithKakaoAccount(serviceTerms: serviceTerms)
    .subscribe(onNext: { (oauthToken) in
        print("loginWithKakaoAccount(serviceTerms:) success.")        
        // Do something
        _ = oauthToken
    }, onError: {error in
        print(error)
    })
.disposed(by: disposeBag)

The response is the same as the Kakao Login.

Legacy iOS

Declare parameters and set it to serviceTermsTags with the tags for the terms that you want to get consent from users. serviceTermsTags should be a string that includes all terms separated by comma(,).

You can pass parameters when calling Kakao Login. If successful, the Consent screen that only includes the designated terms is prompted to users during the login process.

    // Declare parameters to use for login request 
    var parameters: [String: String] = [:]

    // Add 'serviceTermsTags' in a string format that includes all terms separated by ‘,’
    // ex) "tag1,tag2"
    parameters[KOSessionExtraServiceTermsParameterKey] = <#serviceTermsTags#>

    KOSession.shared()?.open(completionHandler: { (error) in
        // Login callback 
        <#code#>
    }, parameters: parameters)

Flutter Login required

Before using the Flutter SDK, you must complete the prerequisites.

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

Parameter
Name Type Description Required
serviceTerms List<String> Tags for the terms that are required to consent. O
Sample
// Getting consent to desired terms

// Designate tags for the terms that you want to get consent
// among the terms registered in [My Application] > [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 (e) {
  print('Login fail');
}
Return data

The return data is the same as the Kakao Login.

See more

Web

Android

iOS