Methods
Below are the methods provided by the Wepin Flutter 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
provider
<String>
The OAuth login provider (e.g., 'google', 'naver', 'discord', 'apple')
clientId
<String>
The client ID of the OAuth login provider
Returns
Future<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
<WepinOauthTokenType>
The type of OAuth token (e.g., idToken, accessToken)
Exception
Example
signUpWithEmailAndPassword
Signs up to Wepin Firebase using an email and password. If the sign-up is successful, it returns Firebase login information.
Parameters
email
<String>
User email
password
<String>
User password
locale
<String>
optionalLanguage for the verification email (default value: "en")
Returns
Future<LoginResult>
provider
<String>
The provider used for the login (in this case, 'email')
token
<WepinFBToken>
idToken
<String>
The Wepin Firebase ID token
refreshToken
<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
email
<String>
User emailpassword
<String>
User password
Returns
Future<LoginResult>
provider
<String>
The provider used for the login (in this case, 'email')
token
<WepinFBToken>
idToken
<String>
The Wepin Firebase ID token
refreshToken
<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
idToken
<String>
ID token value to be used for loginsign
<String>
optionalgetSignForLogin()
)Starting from
wepin_flutter_login_lib
version 0.0.5, thesign
value is optional. If you choose to remove the authentication key issued from the Wepin Workspace, you may opt not to use thesign
value. (Wepin Workspace > Development Tools menu > Login tab > Auth Key > Delete)The Auth Key menu is visible only if an authentication key was previously generated.
Returns
Future<LoginResult>
provider
<String>
- The provider used for the login (in this case, 'external_token').token
<WepinFBToken>
idToken
<String>
The Wepin Firebase ID token
refreshToken
<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
provider
<"naver"|"discord">
Provider that issued the access token
accessToken
<String>
Access token value to be used for login
sign
<String>
optionalSignature value for the Access token (returned value of
getSignForLogin()
)Starting from
wepin_flutter_login_lib
version 0.0.5, thesign
value is optional. If you choose to remove the authentication key issued from the Wepin Workspace, you may opt not to use thesign
value.(Wepin Workspace > Development Tools menu > Login tab > Auth Key > Delete)
The Auth Key menu is visible only if an authentication key was previously generated.
Returns
Future<LoginResult>
provider
<String>
The provider used for the login (in this case, 'external_token')
token
<WepinFBToken>
idToken
<String>
The Wepin Firebase ID token
refreshToken
<String>
The Wepin Firebase refresh token
Exception
Example
getRefreshFirebaseToken
Retrieves information on the current Wepin Firebase token.
Parameters
None
Returns
Future<LoginResult>
provider
<String>
The provider used for the login<'google'|'apple'|'naver'|'discord'|'email'|'external_token'>
token
<WepinFBToken>
idToken
<String>
The Wepin Firebase ID tokenrefreshToken
<String>
The Wepin Firebase refresh token
Exception
Example
loginFirebaseWithOauthProvider
This method combines the functionality of loginWithOauthProvider()
, loginWithIdToken()
, and 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 can only be used after the authentication key has been deleted from the Wepin Workspace.
(Wepin Workspace > Development Tools menu > Login tab > Auth Key > Delete)
The Auth Key menu is visible only if an authentication key was previously generated.
Supported Version
Supported from version0.0.5
and later.
Parameters
provider
<String>
The OAuth login provider (e.g., 'google', 'naver', 'discord', 'apple')
clientId
<String>
The client ID of the OAuth login provider
Return Value
Future<LoginResult>
provider
<String>
The provider used for login<'google'|'apple'|'naver'|'discord'|'email'|'external_token'>
token
<WepinFBToken>
idToken
<String>
Wepin Firebase ID tokenrefreshToken
<String>
Wepin Firebase refresh token
Exception
Example
loginWepinWithOauthProvider
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 can only be used after the authentication key has been deleted from the Wepin Workspace.
(Wepin Workspace > Development Tools menu > Login tab > Auth Key > Delete)
The Auth Key menu is visible only if an authentication key was previously generated.
Supported Version
Supported from version0.0.5
and later.
Parameters
provider
<String>
The OAuth login provider (e.g., 'google', 'naver', 'discord', 'apple')
clientId
<String>
The client ID of the OAuth login provider
Returns
Future<WepinUser> - A Future that resolves to a
WepinUser
object containing the user's login status and information.status
<'success'|'fail'>
The login status.
userInfo
<WepinUserInfo>
optional - The user's information, including:userId
<String>
The user's ID
email
<String>
The user's email
provider
<'google'|'apple'|'naver'|'discord'|'email'|'external_token'>
The login provider
use2FA
<bool>
Whether the user uses two-factor authentication
walletId
<String>
The user's wallet ID
userStatus
<WepinUserStatus>
-The user's Wepin login status, including:loginStats
<'complete' | 'pinRequired' | 'registerRequired'>
If the user's
loginStatus
value is not 'complete', the user must register with Wepin.pinRequired
<bool>
optionalWhether a PIN is required
token
<Token>
The user's Wepin token
accessToken
<String>
The access tokenrefreshToken
<String>
The refresh token
Exception
Example
loginWepinWithIdToken
This method integrates the functions of loginWithIdToken()
and loginWepin()
. The loginWepinWithIdToken()
method logs the user into Wepin using an external ID token. Upon successful login, it returns Wepin user information.
Supported Version
Supported from version0.0.5
and later.
Parameters
idToken
<String>
The ID token to be used for loginsign
<String>
optionalgetSignForLogin()
)
If you choose to remove the authentication key issued from the Wepin Workspace, you may opt not to use the sign
value.
(Wepin Workspace > Development Tools menu > Login tab > Auth Key > Delete)
The Auth Key menu is visible only if an authentication key was previously generated.
Returns
Future<WepinUser> - A Future that resolves to a
WepinUser
object containing the user's login status and information.status
<'success'|'fail'>
The login status
userInfo
<WepinUserInfo>
optional - The user's information, including:userId
<String>
The user's ID
email
<String>
The user's email
provider
<'google'|'apple'|'naver'|'discord'|'email'|'external_token'>
The login provider
use2FA
<bool>
Whether the user uses two-factor authentication
walletId
<String>
The user's wallet ID
userStatus
<WepinUserStatus>
-The user's Wepin login status, including:loginStats
<'complete' | 'pinRequired' | 'registerRequired'>
If the user's
loginStatus
value is not 'complete', the user must register with Wepin.pinRequired
<bool>
optionalWhether a PIN is required
token
<Token>
The user's Wepin token
accessToken
<String>
The access tokenrefreshToken
<String>
The refresh token
Exception
Example
loginWepinWithAccessToken
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.
Supported Version
Supported from version0.0.5
and later.
Parameters
provider
<"naver"|"discord">
Provider that issued the access token
accessToken
<String>
Access token value to be used for login
sign
<String>
optionalSignature value for the Access token (returned value of
getSignForLogin()
)If you choose to remove the authentication key issued from the Wepin Workspace, you may opt not to use the
sign
value.(Wepin Workspace > Development Tools menu > Login tab > Auth Key > Delete)
The Auth Key menu is visible only if an authentication key was previously generated.
Returns
Future<WepinUser> - A Future that resolves to a
WepinUser
object containing the user's login status and information.status
<'success'|'fail'>
The login status
userInfo
<WepinUserInfo>
optional - The user's information, including:userId
<String>
The user's ID
email
<String>
The user's email
provider
<'google'|'apple'|'naver'|'discord'|'email'|'external_token'>
The login provider.
use2FA
<bool>
Whether the user uses two-factor authentication
walletId
<String>
The user's wallet ID
userStatus
<WepinUserStatus>
-The user's Wepin login status, including:loginStats
<'complete' | 'pinRequired' | 'registerRequired'>
If the user's
loginStatus
value is not 'complete', the user must register with Wepin.pinRequired
<bool>
optionalWhether a PIN is required
token
<Token>
The user's Wepin token
accessToken
<String>
The access tokenrefreshToken
<String>
The refresh token
Exception
Example
loginWepinWithEmailAndPassword
his 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.
Supported Version
Supported from version0.0.5
and later.
Parameters
email
<String>
User email.password
<String>
User password.
Returns
Future<WepinUser> - A Future that resolves to a
WepinUser
object containing the user's login status and information.status
<'success'|'fail'>
The login status
userInfo
<WepinUserInfo>
optional - The user's information, including:userId
<String>
The user's ID
email
<String>
The user's email
provider
<'google'|'apple'|'naver'|'discord'|'email'|'external_token'>
The login provider
use2FA
<bool>
Whether the user uses two-factor authentication.
walletId
<String>
The user's wallet ID
userStatus
<WepinUserStatus>
-The user's Wepin login status, including:loginStats
<'complete' | 'pinRequired' | 'registerRequired'>
If the user's
loginStatus
value is not 'complete', the user must register with WepinpinRequired
<bool>
optionalWhether a PIN is required
token
<Token>
The user's Wepin token
accessToken
<String>
The access tokenrefreshToken
<String>
The 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()
, orloginWithAccessToken()
.
Returns
Future<WepinUser> - A Future that resolves to a
WepinUser
object containing the user's login status and information.status
<'success'|'fail'>
The login status.
userInfo
<WepinUserInfo>
optional - The user's information, including:userId
<String>
The user's ID
email
<String>
The user's email
provider
<'google'|'apple'|'naver'|'discord'|'email'|'external_token'>
The login provider
use2FA
<bool>
Whether the user uses two-factor authentication
walletId
<String>
The user's wallet ID
userStatus
<WepinUserStatus>
-The user's Wepin login status, including:loginStats
<'complete' | 'pinRequired' | 'registerRequired'>
If the user's
loginStatus
value is not 'complete', the user must register with Wepin.pinRequired
<bool>
optionalWhether a PIN is required
token
<Token>
The user's Wepin token
accessToken
<String>
The access tokenrefreshToken
<String>
The refresh token
Exception
Example
getCurrentWepinUser
Retrieves information about the currently logged-in user in Wepin.
Parameters
None
Returns
Future<WepinUser> - A Future that resolves to a
WepinUser
object containing the user's login status and information.status
<'success'|'fail'>
The login status.
userInfo
<WepinUserInfo>
optional - The user's information, including:userId
<String>
The user's ID
email
<String>
The user's email
provider
<'google'|'apple'|'naver'|'discord'|'email'|'external_token'>
The login provider
use2FA
<bool>
Whether the user uses two-factor authentication
walletId
<String>
The user's wallet ID
userStatus
<WepinUserStatus>
-The user's Wepin login status, including:loginStats
<'complete' | 'pinRequired' | 'registerRequired'>
If the user's
loginStatus
value is not 'complete', the user must register with WepinpinRequired
<bool>
optionalWhether a PIN is required
token
<Token>
The user's Wepin token
accessToken
<String>
The access tokenrefreshToken
<String>
The refresh token
Exception
Example
logout
Logs out the currently logged-in user from Wepin.
Parameters
None
Returns
Future<bool>
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 generation.
message
<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:
Example
finalize
Terminates the Wepin Login Library.
Parameters
None
Returns
Future<void> A Future that resolves when the finalization process is complete.
Example
WepinError
Error Code | Error Message | Error Description |
---|---|---|
| "InvalidAppKey" | The Wepin app key is invalid. |
| "InvalidParameters" | One or more parameters provided are invalid or missing. |
| "InvalidLoginProvider" | The login provider specified is not supported or is invalid. |
| "InvalidToken" | The token does not exist. |
| "InvalidLoginSession" | The login session information does not exist. |
| "NotInitialized" | The WepinLoginLibrary has not been properly initialized. |
| "AlreadyInitialized" | The WepinLoginLibrary is already initialized, so the logout operation cannot be performed again. |
| "UserCancelled" | The user has cancelled the operation. |
| "UnknownError" | An unknown error has occurred, and the cause is not identified. |
| "NotConnectedInternet" | The system is unable to detect an active internet connection. |
| "FailedLogin" | The login attempt has failed due to incorrect credentials or other issues. |
| "AlreadyLogout" | The user is already logged out, so the logout operation cannot be performed again. |
| "InvalidEmailDomain" | The provided email address's domain is not allowed or recognized by the system. |
| "FailedSendEmail" | 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. |
| "RequiredEmailVerified" | Email verification is required to proceed with the requested operation. |
| "incorrectEmailForm" | The provided email address does not match the expected format. |
| "IncorrectPasswordForm" | The provided password does not meet the required format or criteria. |
| "NotInitializedNetwork" | The network or connection required for the operation has not been properly initialized. |
| "RequiredSignupEmail" | The user needs to sign up with an email address to proceed. |
| "FailedEmailVerified" | The WepinLoginLibrary encountered an issue while attempting to verify the provided email address. |
| "FailedPasswordStateSetting" | Failed to set the password state. This error may occur during password management operations, potentially due to invalid input or system issues. |
| "failedPasswordSetting" | Failed to set the password. This could be due to issues with the provided password or internal errors during the password setting process. |
| "ExistedEmail" | The provided email address is already registered. This error occurs when attempting to sign up with an email that is already in use. |
| "ApiRequestError" | There was an error while making the API request. This can happen due to network issues, invalid endpoints, or server errors. |
| "IncorrectLifecycleException" | The lifecycle of the Wepin SDK is incorrect for the requested operation. Ensure that the SDK is in the correct state (e.g., |
| "FailedRegister" | Failed to register the user. This can occur due to issues with the provided registration details or internal errors during the registration process. |
| "AccountNotFound" | The specified account was not found. This error is returned when attempting to access an account that does not exist in the Wepin. |
| "NftNotFound" | The specified NFT was not found. This error occurs when the requested NFT does not exist or is not accessible within the user's account. |
| "FailedSend" | Failed to send the required data or request. This error could be due to network issues, incorrect data, or internal server errors. |
Last updated