Methods
Below are the methods provided by the Wepin Compose Multiplatform Login Library.
loginWithOauthProvider
suspend fun loginWithOauthProvider(params: LoginOauth2Params): LoginOauthResult
Opens an in-app browser and logs in to the OAuth provider. To retrieve Firebase login information, you need to call the loginWithIdToken()
or loginWithAccessToken()
methods.
Parameters
params
<LoginOauth2Params>
provider
<'google'|'naver'|'discord'|'apple'>
The OAuth login ProviderclientId
<String>
The client ID of the OAuth login provider
Returns
<LoginOauthResult>
provider
<String>
The name of the OAuth provider used.token
<String>
The accessToken (if provider is "naver" or "discord") or idToken (if provider is "google" or "apple")type
<OauthTokenType>
The type of OAuth token (e.g., idToken, accessToken)
Exception
Example
coroutineScope.launch {
wepinLogin.loginWithOauthProvider(LoginOauth2Params(
provider = "google",
clientId = "your-google-client-id",
))
}
signUpWithEmailAndPassword
suspend fun signUpWithEmailAndPassword(params: LoginWithEmailParams): LoginResult
Sign up for Wepin Firebase with an email and password. For users who have not yet registered, a verification email will be sent, and a REQUIRED_EMAIL_VERIFIED
error will occur if verification is required. If the user is already registered, an EXISTED_EMAIL
error will occur, and you should proceed with the login process by calling loginWithEmailAndPassword. Upon successful login, Firebase login information is returned.
Parameters
params
<LoginWithEmailParams>
email
<String>
User emailpassword
<String>
User passwordlocale
<String>
Language for the verification email (default value: "en")
Returns
<LoginResult>
provider
<Providers.EMAIL>
The provider used for the login (in this case, 'email')token
<FBToken>
idToken
<String>
The Wepin Firebase ID tokenrefreshToken
<String>
The Wepin Firebase refresh token
Exception
Example
coroutineScope.launch {
wepinLogin.signUpWithEmailAndPassword(
LoginWithEmailParams(
email = "[email protected]",
password = "abcdef123$"
)
)
}
loginWithEmailAndPassword
suspend fun loginWithEmailAndPassword(params: LoginWithEmailParams): LoginResult
Logs in to Wepin Firebase using an email and password. If the login is successful, it returns Firebase login information.
Parameters
params
<LoginWithEmailParams>
email
<String>
User emailpassword
<String>
User password
Returns
<LoginResult>
provider
<Providers.EMAIL>
The provider used for the login (in this case, 'email')token
<FBToken>
idToken
<String>
The Wepin Firebase ID tokenrefreshToken
<String>
The Wepin Firebase refresh token
Exception
Example
coroutineScope.launch {
wepinLogin.loginWithEmailAndPassword(
LoginWithEmailParams(
email = "[email protected]",
password = "abcdef123$"
)
)
}
loginWithIdToken
suspend fun loginWithIdToken(params: LoginOauthIdTokenRequest): LoginResult
Logs in to Wepin Firebase using an external ID token. If the login is successful, it returns Firebase login information.
Parameters
params
<LoginOauthIdTokenRequest>
idToken
<String>
ID token value to be used for loginsign
<String>
(optional) Signature value for the token provided as the first parameter (returned value ofgetSignForLogin()
)
Returns
<LoginResult>
provider
<Providers.EXTERNAL_TOKEN>
The provider used for the logintoken
<FBToken>
idToken
<String>
The Wepin Firebase ID tokenrefreshToken
<String>
The Wepin Firebase refresh token
Exception
Example
coroutineScope.launch {
try {
val loginOption = LoginOauthIdTokenRequest(idToken = token)
val loginResponse = wepinLogin.loginWithIdToken(loginOption)
setResponse(loginResponse)
setText("$loginResponse")
} catch (e: Exception) {
setResponse(null)
setText("fail - ${e.message}")
}
}
loginWithAccessToken
suspend fun loginWithAccessToken(params: LoginOauthAccessTokenRequest): LoginResult
Logs in to Wepin Firebase using an external access token. If the login is successful, it returns Firebase login information.
Parameters
params
<LoginOauthAccessTokenRequest>
provider
<'naver'|'discord'|'facebook'>
Provider that issued the access token.accessToken
<String>
Access token value to be used for login.sign
<String>
(optional)getSignForLogin()
).
Returns
<LoginResult>
provider
<Providers.EXTERNAL_TOKEN>
The provider used for the logintoken
<FBToken>
idToken
<String>
The Wepin Firebase ID tokenrefreshToken
<String>
The Wepin Firebase refresh token
Exception
Example
coroutineScope.launch {
try {
val loginOption = LoginOauthAccessTokenRequest(provider, token)
val loginResponse = wepinLogin.loginWithAccessToken(loginOption)
setResponse(loginResponse)
setText("$loginResponse")
} catch (e: Exception) {
setResponse(null)
setText("fail - ${e.message}")
}
}
getRefreshFirebaseToken
suspend fun getRefreshFirebaseToken(): LoginResult
Retrieves information on the current Wepin Firebase token.
Parameters
None
Returns
<LoginResult>
provider
<Providers.EXTERNAL_TOKEN>
The provider used for the logintoken
<FBToken>
idToken
<String>
The Wepin Firebase ID tokenrefreshToken
<String>
The Wepin Firebase refresh token.
Exception
Example
coroutineScope.launch {
wepinLogin.getRefreshFirebaseToken()
}
loginFirebaseWithOauthProvider
Supported from version 0.0.10
and later.
suspend fun loginFirebaseWithOauthProvider(params: LoginOauth2Params): LoginResult?
This method combines the functionality of loginWithOauthProvider
, loginWithIdToken
, loginWithAccessToken
. It opens an in-app browser to log in to Wepin Firebase through the specified OAuth login provider. Upon successful login, it returns Firebase login information. This method is a suspend method, so you can call it within another suspend method or in a coroutine.
Parameters
params
<
LoginOauth2Params>
provider
<'google'|'naver'|'discord'|'apple'>
The OAuth login ProviderclientId
<String>
The client ID of the OAuth login provider
Returns
<LoginResult>
provider
<Providers.EXTERNAL_TOKEN>
The provider used for the logintoken
<FBToken>
idToken
<String>
The Wepin Firebase ID tokenrefreshToken
<String>
The Wepin Firebase refresh token.
Exception
Example
val loginOption = LoginOauth2Params(
provider = "google",
clientId = "google-client-id",
)
coroutineScope.launch {
try {
val loginResponse = wepinLogin.loginFirebaseWithOauthProvider(loginOption)
} catch (e: Exception) {
setResponse(null)
setText("fail - $e")
}
}
loginWepinWithOauthProvider
Supported from version 0.0.10
and later.
suspend fun loginWepinWithOauthProvider(params: LoginOauth2Params): WepinUser?
This method combines the functionality of loginFirebaseWithOauthProvider
and loginWepin
. It opens an in-app browser to log in to Wepin through the specified OAuth login provider. Upon successful login, it returns Wepin user information. This method is a suspend method, so you can call it within another suspend method or in a coroutine.
Parameters
params
<
LoginOauth2Params>
provider
<'google'|'naver'|'discord'|'apple'>
The OAuth login ProviderclientId
<String>
The client ID of the OAuth login provider
Returns
<WepinUser> (optional)
status
<'success' | 'fail'>
The login statususerInfo
<UserInfo>
(optional) The user's information, including:userId
<String>
The user's IDemail
<String>
The user's emailprovider
<'google'|'naver'|'discord'|'apple'|'email' | 'external_token'>
The login provideruse2FA
<Boolean>
Whether the user uses two-factor authentication
walletId
<String>
The user's wallet IDuserStatus
<UserStatus>
(optional) The user's Wepin login status, including:loginStatus
<WepinLoginStatus - 'complete' | 'pinRequired' | 'registerRequired'>
If the user'sloginStatus
value is not 'complete', the user must register with Wepin.pinRequired
<Boolean>
Whether a PIN is required
token
<Token>
The user's Wepin tokenaccessToken
<String>
The access tokenrefreshToken
<String>
The refresh token
Exception
Example
val loginOption = LoginOauth2Params(
provider = "google",
clientId = "google-client-id",
)
coroutineScope.launch {
try {
val userInfo = wepinLogin.loginWepinWithOauthProvider(loginOption)
} catch (e: Exception) {
setResponse(null)
setText("fail - $e")
}
}
loginWepinWithEmailAndPassword
Supported from version 0.0.10
and later.
suspend fun loginWepinWithEmailAndPassword(params: LoginWithEmailParams): WepinUser?
This method integrates the functions of loginWithEmailAndPassword
and loginWepin
. The loginWepinWithEmailAndPassword
method logs the user into Wepin using the provided email and password. Upon successful login, it returns Wepin user information. This method is a suspend method, so you can call it within another suspend method or in a coroutine.
Parameters
params
<LoginWithEmailParams>
email
<String>
User emailpassword
<String>
User password
Returns
<WepinUser> (optional)
status
<'success' | 'fail'>
The login statususerInfo
<UserInfo>
(optional) The user's information, including:userId
<String>
The user's IDemail
<String>
The user's emailprovider
<'google'|'naver'|'discord'|'apple'|'email' | 'external_token'>
The login provideruse2FA
<Boolean>
Whether the user uses two-factor authentication
walletId
<String>
The user's wallet IDuserStatus
<UserStatus>
(optional) The user's Wepin login status, including:loginStatus
<WepinLoginStatus - 'complete' | 'pinRequired' | 'registerRequired'>
If the user'sloginStatus
value is not 'complete', the user must register with Wepin.pinRequired
<Boolean>
Whether a PIN is required
token
<Token>
The user's Wepin tokenaccessToken
<String>
The access tokenrefreshToken
<String>
The refresh token
Exception
Example
val loginOption = LoginWithEmailParams(email, password)
coroutineScope.launch {
try {
val response = wepinLogin.loginWepinWithEmailAndPassword(loginOption)
setResponse(response)
setText("$response")
} catch (e: Exception) {
setText("fail - $e")
}
}
loginWepinWithIdToken
Supported from version 0.0.10
and later.
suspend fun loginWepinWithIdToken(params: LoginOauthIdTokenRequest): WepinUser?
This method integrates the funcions of loginWithIdToken
and loginWepin
. The loginWepinWithIdToken
method logs the user info Wepin using an external ID token. Upon successful login, it returns Wepin user information. This method is a suspend method, so you can call it within another suspend method or in a coroutine.
Parameters
params
<LoginOauthIdTokenRequest>
idToken
<String>
ID token value to be used for loginsign
<String>
(optional) Signature value for the token provided as the first parameter (returned value ofgetSignForLogin()
)
Returns
<WepinUser> (optional)
status
<'success' | 'fail'>
The login statususerInfo
<UserInfo>
(optional) The user's information, including:userId
<String>
The user's IDemail
<String>
The user's emailprovider
<'google'|'naver'|'discord'|'apple'|'email' | 'external_token'>
The login provideruse2FA
<Boolean>
Whether the user uses two-factor authentication
walletId
<String>
The user's wallet IDuserStatus
<UserStatus>
(optional) The user's Wepin login status, including:loginStatus
<WepinLoginStatus - 'complete' | 'pinRequired' | 'registerRequired'>
If the user'sloginStatus
value is not 'complete', the user must register with Wepin.pinRequired
<Boolean>
Whether a PIN is required
token
<Token>
The user's Wepin tokenaccessToken
<String>
The access tokenrefreshToken
<String>
The refresh token
Exception
Example
coroutineScope.launch {
try {
val loginOption = LoginOauthIdTokenRequest(idToken = token)
val userInfo = wepinLogin.loginWepinWithIdToken(loginOption)
} catch (e: Exception) {
setResponse(null)
setText("fail - ${e.message}")
}
}
loginWepinWithAccessToken
Supported from version 0.0.10
and later.
suspend fun loginWepinWithAccessToken(params: LoginOauthAccessTokenRequest): WepinUser?
This method integrates the functions of loginWithAccessToken
and loginWepin
. The loginWepinWithAccessToken
method logs the user into Wepin using an external access token. Upon successful login, it returns Wepin user information. This method is a suspend method, so you can call it within another suspend method or in a coroutine.
Parameters
params
<LoginOauthAccessTokenRequest>
provider
<'naver'|'discord'|'facebook'>
Provider that issued the access token.accessToken
<String>
Access token value to be used for login.sign
<String>
(optional)getSignForLogin()
).
Returns
<WepinUser> (optional)
status
<'success' | 'fail'>
The login statususerInfo
<UserInfo>
(optional) The user's information, including:userId
<String>
The user's IDemail
<String>
The user's emailprovider
<'google'|'naver'|'discord'|'apple'|'email' | 'external_token'>
The login provideruse2FA
<Boolean>
Whether the user uses two-factor authentication
walletId
<String>
The user's wallet IDuserStatus
<UserStatus>
(optional) The user's Wepin login status, including:loginStatus
<WepinLoginStatus - 'complete' | 'pinRequired' | 'registerRequired'>
If the user'sloginStatus
value is not 'complete', the user must register with Wepin.pinRequired
<Boolean>
Whether a PIN is required
token
<Token>
The user's Wepin tokenaccessToken
<String>
The access tokenrefreshToken
<String>
The refresh token
Exception
Example
coroutineScope.launch {
try {
val loginOption = LoginOauthAccessTokenRequest(provider, token)
val userInfo = wepinLogin.loginWepinWithAccessToken(loginOption)
setResponse(userInfo)
setText("$userInfo")
} catch (e: Exception) {
setResponse(null)
setText("fail - ${e.message}")
}
}
loginWepin
suspend fun loginWepin(params: LoginResult?): WepinUser
Logs the user into Wepin using the Wepin Firebase token.
Parameters
params
<LoginResult>
Parameters from the return value of methods likeloginWithEmailAndPassword()
,loginWithIdToken()
, orloginWithAcccessToken()
Returns
<WepinUser> (optional)
status
<'success' | 'fail'>
The login statususerInfo
<UserInfo>
(optional) The user's information, including:userId
<String>
The user's IDemail
<String>
The user's emailprovider
<'google'|'naver'|'discord'|'apple'|'email' | 'external_token'>
The login provideruse2FA
<Boolean>
Whether the user uses two-factor authentication
walletId
<String>
The user's wallet IDuserStatus
<UserStatus>
(optional) The user's Wepin login status, including:loginStatus
<WepinLoginStatus - 'complete' | 'pinRequired' | 'registerRequired'>
If the user'sloginStatus
value is not 'complete', the user must register with Wepin.pinRequired
<Boolean>
Whether a PIN is required
token
<Token>
The user's Wepin tokenaccessToken
<String>
The access tokenrefreshToken
<String>
The refresh token
Exception
Example
coroutineScope.launch {
val wepinLogin: WepinLogin = WepinLogin(
WepinLoginOptions(
context = context,
appId = appId,
appKey = appKey
)
)
wepinLogin.init()
val response = wepinLogin.loginWithOauthProvider(
LoginOauth2Params(
provider = "google",
clientId = "your-google-client-id"
)
)
val sign = wepinLogin.getSignForLogin(
privateKeyHex = "private key",
message = response.token
)
var loginResult: LoginResult? = null
if (response.provider == "naver" || response.provider = "discord") {
loginResult = wepinLogin.loginWithAccessToken(
LoginOauthAccessTokenRequest(
provider = response.provider,
token = response.token,
sign = sign
)
)
} else {
loginResult = wepinLogin.loginWithIdToken(
LoginOauthIdTokenRequest(
idToken = response.token,
sign = sign
)
)
}
val userInfo = wepinLogin.loginWepin(loginResult)
val userStatus = userInfo.userStatus
if (userStatus.loginStatus != WepinLoginStatus.COMPLETE) {
//Wepin Register 코드..
}
}
getCurrentWepinUser
suspend fun getCurrentWepinUser(): WepinUser
Retrieves information about the currently logged-in user in Wepin.
Parameters
None
Returns
<WepinUser>
status
<'success' | 'fail'>
The login statususerInfo
<UserInfo>
(optional) The user's information, including:userId
<String>
The user's IDemail
<String>
The user's emailprovider
<'google'|'naver'|'discord'|'apple'|'email' | 'external_token'>
The login provideruse2FA
<Boolean>
Whether the user uses two-factor authentication
walletId
<String>
The user's wallet IDuserStatus
<UserStatus>
(optional) The user's Wepin login status, including:loginStatus
<WepinLoginStatus - 'complete' | 'pinRequired' | 'registerRequired'>
If the user'sloginStatus
value is not 'complete', the user must register with Wepin.pinRequired
<Boolean>
Whether a PIN is required
token
<Token>
The user's Wepin tokenaccessToken
<String>
The access tokenrefreshToken
<String>
The refresh token
Exception
Example
coroutineScope.launch {
val userInfo = wepinLogin.getCurrentWepinUser()
val userStatus = userInfo.userStatus!!
if (userStatus.loginStatus != WepinLoginStatus.COMPLETE) {
//Wepin Register 코드..
}
}
logoutWepin
suspend fun logoutWepin(): Boolean
Logs out the currently logged-in user from Wepin.
Parameters
None
Returns
<Boolean>
Exception
Example
coroutineScope.launch {
wepinLogin.logoutWepin()
}
getSignForLogin
fun getSignForLogin(privateKeyHex: String, message: String): String
Generates a signature for verifying the issuer. This method is mainly used to generate signatures for login-related information such as ID tokens and access tokens.
Parameters
privateKey
<String>
The authentication key used for signature generationmessage
<String>
The message or payload to be signed
Returns
<String> - The generated signature
The private key (privateKey) must be securely stored and should not be exposed externally. To enhance security and protect sensitive information, it is recommended to execute the getSignForLogin()
method on the backend rather than the frontend. For details on how to generate signatures, please refer to the following document.
Exception
Example
wepinLogin.getSignForLogin(
privateKeyHex = "private key",
message = "idtokenoraccesstoken"
)
finalize
fun finalize()
Terminates the Wepin Login Library.
Parameters
None
Returns
None
Exception
Example
wepinLogin.finalize()
Wepin Error
INVALID_APP_KEY
"Invalid app key"
The Wepin app key is invalid.
INVALID_PARAMETER
`
"Invalid parameter"
One or more parameters provided are invalid or missing.
INVALID_LOGIN_PROVIDER
"Invalid login provider"
The login provider specified is not supported or is invalid.
INVALID_TOKEN
"Token does not exist"
The token does not exist.
INVALID_LOGIN_SESSION
"Invalid Login Session"
The login session information does not exist.
NOT_INITIALIZED_ERROR
"Not initialized error"
The WepinLoginLibrary has not been properly initialized.
ALREADY_INITIALIZED_ERROR
"Already initialized"
The WepinLoginLibrary is already initialized, so the logout operation cannot be performed again.
NOT_ACTIVITY
"Context is not activity"
The Context is not an activity
USER_CANCELLED
"User cancelled"
The user has cancelled the operation.
UNKNOWN_ERROR
"An unknown error occurred"
An unknown error has occurred, and the cause is not identified.
NOT_CONNECTED_INTERNET
"No internet connection"
The system is unable to detect an active internet connection.
FAILED_LOGIN
"Failed to Oauth log in"
The login attempt has failed due to incorrect credentials or other issues.
ALREADY_LOGOUT
"Already Logout"
The user is already logged out, so the logout operation cannot be performed again.
INVALID_EMAIL_DOMAIN
"Invalid email domain"
The provided email address's domain is not allowed or recognized by the system.
FAILED_SEND_EMAIL
"Failed to send email"
The system encountered an error while sending an email. This is because the email address is invalid or we sent verification emails too often. Please change your email or try again after 1 minute.
REQUIRED_EMAIL_VERIFIED
"Email verification required"
Email verification is required to proceed with the requested operation.
INCORRECT_EMAIL_FORM
"Incorrect email format"
The provided email address does not match the expected format.
INCORRECT_PASSWORD_FORM
"Incorrect password format"
The provided password does not meet the required format or criteria.
NOT_INITIALIZED_NETWORK
"Network Manager not initialized"
The network or connection required for the operation has not been properly initialized.
REQUIRED_SIGNUP_EMAIL
"Email sign-up required."
The user needs to sign up with an email address to proceed.
FAILED_EMAIL_VERIFIED
"Failed to verify email."
The WepinLoginLibrary encountered an issue while attempting to verify the provided email address.
FAILED_PASSWORD_SETTING
"Failed to set password."
The WepinLoginLibrary failed to set the password.
EXISTED_EMAIL
"Email already exists."
The provided email address is already registered in Wepin.
Last updated
Was this helpful?