Namespace: Auth

Kakao. Auth

Include functions related to user authentication.

Methods


<static> cleanup()

Deactivate resource and delete iframe inserted for creating login button.


<static> createLoginButton(settings)

Create Kakao login button. It is suggested to use Kakao.Auth.login when creating button manually.

Parameters:
Name Type Description
settings Object

Attributes of login button are passed by 'key/value' format.

Properties
Name Type Argument Default Description
container String | DOMElement

ID Selector or DOM Element of a container that will be displayed in login button

lang "kr" | "en" <optional>
"kr"

Language to be used in login button

size "small" | "medium" | "large" <optional>
"medium"

Size of login button

success AuthSuccessCallback <optional>

The callback function is called to get user token, when login succeed.

fail AuthFailCallback <optional>

The callback function is called to get errorMessage, when login failed.

always AuthSuccessCallback | AuthFailCallback <optional>

The callback function is called, when login failed or succeed.

persistAccessToken Boolean <optional>
true

Even if session expires, Access Token will be saved in local storage for later use. Save Access Token to local storage, in order to use Access Token after session expires.

persistRefreshToken Boolean <optional>
false

Even if session expires, Refresh Token will be saved in local storage for later use. Save Refresh Token to local storage, in order to use Refresh Token after session expires.


<static> getAccessToken()

Return Access Token in use.

Returns:

Access Token in use

Type
String

<static> getAppKey()

Return App Key in use.

Returns:

App Key in use

Type
String

<static> getRefreshToken()

Deprecated:
  • This API is deprecated due to security policies.

<static> getStatus( [callback])

Return current login status.

Parameters:
Name Type Argument Description
callback AuthStatusCallback <optional>

The callback function to return login status


<static> login(settings)

This is a function for helping App login through login pop up window. this must be called after users click event in order to make sure that browser does not block window.if it is not necessary to make custom login button refer Kakao.Auth.createLoginButton.

Parameters:
Name Type Description
settings Object

Attributes of login button are passed by 'key/value' format.

Properties
Name Type Argument Default Description
success AuthSuccessCallback <optional>

The callback function is called to get user token, when login succeed.

fail AuthFailCallback <optional>

The callback function is called to get errorMessage, when login failed.

always AuthSuccessCallback | AuthFailCallback <optional>

The callback function is called, when login failed or succeed.

persistAccessToken Boolean <optional>
true

Even if session expires, Access Token will be saved in local storage for later use. Save Access Token to local storage, in order to use Access Token after session expires.

persistRefreshToken Boolean <optional>
false

Even if session expires, Refresh Token will be saved in local storage for later use. Save Refresh Token to local storage, in order to use Refresh Token after session expires.

throughTalk Boolean <optional>
true

Whether to use simple login


<static> loginForm(settings)

The function that pops up the login window so that you can log in to another account. The popup is not blocked by the browser until it is called after the user's click event.

Parameters:
Name Type Description
settings Object

Attributes of login button are passed by 'key/value' format.

Properties
Name Type Argument Default Description
success AuthSuccessCallback <optional>

The callback function is called to get user token, when login succeed.

fail AuthFailCallback <optional>

The callback function is called to get errorMessage, when login failed.

always AuthSuccessCallback | AuthFailCallback <optional>

The callback function is called, when login failed or succeed.

persistAccessToken Boolean <optional>
true

Even if session expires, Access Token will be saved in local storage for later use. Save Access Token to local storage, in order to use Access Token after session expires.

persistRefreshToken Boolean <optional>
false

Even if session expires, Refresh Token will be saved in local storage for later use. Save Refresh Token to local storage, in order to use Refresh Token after session expires.


<static> logout( [callback])

Log out currently logged in user and delete both Access Token and Refresh Token.

Parameters:
Name Type Argument Description
callback function <optional>

The callback function is called after logout


<static> setAccessToken(token [, persist])

Set Access Token that wil be used, when calling API.

Parameters:
Name Type Argument Default Description
token String

Access Token that will be used

persist Boolean <optional>
false

Even if session expires, Access Token will be saved in local storage for later use. Save Access Token to local storage, in order to use Access Token after session expires.


<static> setRefreshToken()

Deprecated:
  • This API is deprecated due to security policies.

Type Definitions


AuthFailCallback(errorObj)

Kakao.Auth fail callback

Parameters:
Name Type Description
errorObj Object
Properties
Name Type Description
error String

"access_denied"

error_description String

AuthStatusCallback(statusObj)

Parameters:
Name Type Description
statusObj Object
Properties
Name Type Description
status "connected" | "not_connected"
user UserObject

AuthSuccessCallback(authObj)

Kakao.Auth success callback

Parameters:
Name Type Description
authObj Object
Properties
Name Type Description
access_token String
refresh_token String
token_type String

"bearer"

expires_in Number
scope String