Toss Login
For service introduction and console setup instructions, Toss Login introduction documentplease refer to.
Basic information
Base URL
https://apps-in-toss-api.toss.im
Server authentication
mTLS (client certificate)
Content-Type
application/json
1. Get an authorization code
SDK function: appLogin
appLoginuses the authentication flow of the Toss app to perform login, and when login succeeds, an authorization code (authorizationCode).
When you perform Toss Login for the first time appLogin If you call the function, the Toss Login window opens and the terms consent screen registered in the Apps in Toss console is shown. If the user agrees to the required terms, an authorization code is returned.
If Toss Login has already been performed appLogin If you call the function, an authorization code is returned immediately without a separate login window.
Signature
Return value
authorizationCode string
This is the authorization code issued after user authentication is completed. Send it to the server and exchange it for an AccessToken.
referrer string
Indicates the environment from which the login request occurred. DEFAULT: real Toss app environment, SANDBOX: sandbox environment
Example: Example of logging in through Toss authentication
Try the sample app
apps-in-toss-examples from the repository with-app-login Download the code and try it out.
2. Receive AccessToken
For calling the user information lookup API issue an access token.
Content-Type:
application/jsonMethod:
POSTURL:
/api-partner/v1/apps-in-toss/user/oauth2/generate-token
Request
authorizationCode
string
Y
Authorization code
referrer
string
Y
referrer
Success response
tokenType
string
Y
fixed as bearer
accessToken
string
Y
accessToken
refreshToken
string
Y
refreshToken
expiresIn
string
Y
expiration time (seconds)
scope
string
Y
authorized scope (delimiter)
Failure response If the authorization code has expired or if you request AccessToken multiple times with the same authorization code
3. Receive AccessToken again
Reissue an access token for calling the user information lookup API.
Content-type : application/json
Method :
POSTURL :
/api-partner/v1/apps-in-toss/user/oauth2/refresh-token
Request
refreshToken
string
Y
Issued RefreshToken
Success response
tokenType
string
Y
fixed as bearer
accessToken
string
Y
accessToken
refreshToken
string
Y
refreshToken
expiresIn
string
Y
expiration time (seconds)
scope
string
Y
authorized scope (delimiter)
Failure response
errorCode
string
Y
Error code
reason
string
Y
Error message
4. Receive user information
Look up user information. DIis nullis returned, and can be called without any limit on the number of times. For privacy protection, all personal information is encrypted formprovided in.
Content-type : application/json
Method :
GETURL :
/api-partner/v1/apps-in-toss/user/oauth2/login-me
Request headers
Authorization
string
Y
Authentication request with AccessToken Authorization: Bearer ${AccessToken}
Success response
userKey
number
Y
N
This is a unique user identification value that can be used only in the corresponding app. Even for the same user, userKey may differ if the app is different.
scope
string
Y
N
This is the list of authorized scopes. It includes the values the user consented to among the items selected in the console and user_key items.
agreedTerms
list
Y
N
This is the list of terms the user agreed to.
name
string
N
Y
This is the user's name.
phone
string
N
Y
This is the user's mobile phone number.
birthday
string
N
Y
This is the user's date of birth. (yyyyMMdd)
ci
string
N
Y
This is the user's CI value.
di
string
N
Y
Always null is returned as a value.
gender
string
N
Y
This is the user's gender information. (MALE/FEMALE)
nationality
string
N
Y
This is whether the user is local or foreign. (LOCAL/FOREIGNER)
string
N
Y
This is the user's email information. It is not a verified value.
Failure response If you use an invalid token, check the validity period of the current access_token and reissue it.
Server error response example
INTERNAL_ERROR
Internal server error
USER_KEY_NOT_FOUND
Unable to find the user key value connected to the login service
USER_NOT_FOUND
Unable to find Toss user information
BAD_REQUEST_RETRIEVE_CERT_RESULT_EXCEEDED_LIMIT
Exceeded the number of queries available with the same token /api/login/user/me/without-di When querying the API, it is returned normally, but the di field comes back as null
5. Decrypt user information
Received by email through the console decryption keyand AAD (Additional Authenticated DATA) please proceed with.
Encryption algorithm
AES symmetric-key encryption
Key length: 256 bits
Mode: GCM
AAD: We send it by email together with the decryption key.
Data exchange method
The front part of the encrypted data includes the IV (NONCE).
For decryption, you must extract the IV from the ciphertext and use it for successful decryption.
Decryption sample code
6. Disconnect login
If you no longer use the issued AccessToken or need to expire the token at the user's request, delete(expire) the token.
Content-type : application/json
Method :
POSTURL :
Disconnect with accessToken:
/api-partner/v1/apps-in-toss/user/oauth2/access/remove-by-access-tokenDisconnect with userKey:
/api-partner/v1/apps-in-toss/user/oauth2/access/remove-by-user-key
Disconnect login connection with AccessToken
Disconnect login connection with userKey
7. Disconnect login via callback
If the user disconnects from the service within the Toss app, we will inform the merchant server. You can use this when the service needs to handle users whose connection has been disconnected. The URL to receive the callback and the basic Auth header can be entered in the console.
GET method
In the request requestParam
userKeyandreferrerinclude it.
POST method
in the request body
userKeyandreferrerinclude it.
referrer is the disconnect request path.
UNLINK
It is called when the user disconnects directly in the Toss app. (Path: Toss app → Settings → Authentication and Security → Services logged in with Toss → 'Disconnect')
WITHDRAWAL_TERMS
It is called when the user withdraws consent to the login service terms. (Path: Toss app → Settings → Legal information and others → Terms and privacy policy consent → Consent details by service: "Toss Login" → 'Withdraw consent')
WITHDRAWAL_TOSS
It is called when the user withdraws from Toss membership.
Troubleshooting
When an authentication error occurs during local development
There are mainly two reasons why authentication errors occur when developing locally.
Authentication token expired The previously issued authentication token may have expired. Issue a new token and try again.
Unable to log in as a developer You may not be logged in with a developer account in the sandbox environment. Refer to the sandbox app download, log in, and then try again.
Last updated
Was this helpful?