Methods
Below are the methods provided by the Wepin Compose Multiplatform Login Library.
loginWithOauthProvider
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
signUpWithEmailAndPassword
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
loginWithEmailAndPassword
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
loginWithIdToken
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>
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
loginWithAccessToken
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'>
Provider that issued the access token.accessToken
<String>
Access token value to be used for login.sign
<String>
Signature value for the Access token (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
getRefreshFirebaseToken
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
loginWepin
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>
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' | 'apple' | 'naver' | 'discord' | '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
getCurrentWepinUser
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' | 'apple' | 'naver' | 'discord' | '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
logoutWepin
Logs out the currently logged-in user from Wepin.
Parameters
None
Returns
<Boolean>
Exception
Example
getSignForLogin
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
The key for signing can be obtained from Wepin Workspace. In the Development Tools menu, click Get your authentication key on the Login tab to retrieve the authentication key.
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
finalize
Terminates the Wepin Login Library.
Parameters
None
Returns
None
Exception
Example
Wepin Error
Error Code | Error Message | Error Description |
---|---|---|
| "Invalid app key" | The Wepin app key is invalid. |
| "Invalid parameter" | One or more parameters provided are invalid or missing. |
| "Invalid login provider" | The login provider specified is not supported or is invalid. |
| "Token does not exist" | The token does not exist. |
| "Invalid Login Session" | The login session information does not exist. |
| "Not initialized error" | The WepinLoginLibrary has not been properly initialized. |
| "Already initialized" | The WepinLoginLibrary is already initialized, so the logout operation cannot be performed again. |
| "Context is not activity" | The Context is not an activity |
| "User cancelled" | The user has cancelled the operation. |
| "An unknown error occurred" | An unknown error has occurred, and the cause is not identified. |
| "No internet connection" | The system is unable to detect an active internet connection. |
| "Failed to Oauth log in" | The login attempt has failed due to incorrect credentials or other issues. |
| "Already Logout" | The user is already logged out, so the logout operation cannot be performed again. |
| "Invalid email domain" | The provided email address's domain is not allowed or recognized by the system. |
| "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. |
| "Email verification required" | Email verification is required to proceed with the requested operation. |
| "Incorrect email format" | The provided email address does not match the expected format. |
| "Incorrect password format" | The provided password does not meet the required format or criteria. |
| "Network Manager not initialized" | The network or connection required for the operation has not been properly initialized. |
| "Email sign-up required." | The user needs to sign up with an email address to proceed. |
| "Failed to verify email." | The WepinLoginLibrary encountered an issue while attempting to verify the provided email address. |
| "Failed to set password." | The WepinLoginLibrary failed to set the password. |
| "Email already exists." | The provided email address is already registered in Wepin. |
Last updated