Methods
These are the methods provided by the Wepin iOS Login Library.
Methods can be used after initialization of Wepin Login Library.
loginWithOauthProvider
An in-app browser will open and proceed to log in to the OAuth provider. To retrieve Firebase login information, you need to execute either the loginWithIdToken() or loginWithAccessToken() method.
Parameters
params
<WepinLoginOauth2Params>provider
<'google'|'naver'|'discord'|'apple'> - Provider for loginclientId
<String>
viewController
<UIViewController>
Returns
<WepinLoginOauthResult>
provider
<String> - login providertoken
<String> - accessToken (if provider is "naver" or "discord") or idToken (if provider is "google" or "apple")type
<WepinOauthTokenType> - type of token
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 requiredEmailVerified
error will occur if verification is required. If the user is already registered, an existedEmail
error will occur, and you should proceed with the login process by calling loginWithEmailAndPassword. Upon successful login, Firebase login information is returned.
Parameters
params
<WepinLoginWithEmailParams>email
<String> - User emailpassword
<String> - User passwordlocale
<String> - optional Language for the verification email (default value: "en")
Returns
<WepinLoginResult>
provider
<WepinLoginProviders>token
<WepinFBToken>idToken
<String> - wepin firebase idTokenrefreshToken
- wepin firebase refreshToken
Exception
Example
loginWithEmailAndPassword
This function logs in to the Wepin Firebase using your email and password. It returns Firebase login information upon successful login.
Parameters
params
<WepinLoginWithEmailParams>email
<String> - User emailpassword
<String> - User password
Returns
<WepinLoginResult>
provider
<WepinLoginProviders>token
<WepinFBToken>idToken
<String> - wepin firebase idTokenrefreshToken
` - wepin firebase refreshToken
Exception
Example
loginWithIdToken
This function logs in to the Wepin Firebase using an external ID token. It returns Firebase login information upon successful login.
Parameters
params
<WepinLoginOauthIdTokenRequest>idToken
<String> - ID token value to be used for loginsign
<String> - Signature value for the token provided as the first parameter.(Returned value of getSignForLogin())
Returns
<WepinLoginResult>
provider
<WepinLoginProviders>token
<WepinFBToken>idToken
<String> - wepin firebase idTokenrefreshToken
` - wepin firebase refreshToken
Exception
Example
loginWithAccessToken
This function logs in to the Wepin Firebase using an external access token. It returns Firebase login information upon successful login.
Parameters
params
<WepinLoginOauthAccessTokenRequest>provider
<"naver"|"discord"> - Provider that issued the access tokenaccessToken
<String> - Access token value to be used for loginsign
<String> - Signature value for the token provided as the first parameter. (Returned value of getSignForLogin())
Returns
<WepinLoginResult>
provider
<WepinLoginProviders>token
<WepinFBToken>idToken
<String> - wepin firebase idTokenrefreshToken
` - wepin firebase refreshToken
Exception
Example
getRefreshFirebaseToken
This method retrieves the current firebase token's information from the Wepin.
Parameters
void
Returns
<WepinLoginResult>
provider
<WepinLoginProviders>token
<WepinFBToken>idToken
<String> - wepin firebase idTokenrefreshToken
` - wepin firebase refreshToken
Exception
Example
loginWepin
This method logs the user into the Wepin application using the specified provider and token.
Parameters
The parameters should utilize the return values from the loginWithEmailAndPassword()
, loginWithIdToken()
, and loginWithAccessToken()
methods within this module.
<WepinLoginResult>
provider
<WepinLoginProviders>token
<WepinFBToken>idToken
<String> - Wepin Firebase idTokenrefreshToken
` - Wepin Firebase refreshToken
Returns
<WepinUser> - An object containing the user's login status and information. The object includes:
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 <WepinLoginProviders> - 'google'|'apple'|'naver'|'discord'|'email'|'external_token'
use2FA <Bool> - Whether the user uses two-factor authentication.
walletId <String> optional - The user's wallet ID.
userStatus: <WepinUserStatus> optional - The user's status of wepin login. including:
loginStatus: <WepinLoginStatus> - 'complete' | 'pinRequired' | 'registerRequired' - If the user's loginStatus value is not complete, it must be registered in the wepin.
pinRequired: optional
token: <WepinToken> optional - The user's token of wepin.
refresh: <String>
access <String>
Exception
Example
getCurrentWepinUser
This method retrieves the current logged-in user's information from the Wepin.
Parameters
void
Returns
<WepinUser> - An object containing the user's login status and information. The object includes:
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 <WepinLoginProviders> - 'google'|'apple'|'naver'|'discord'|'email'|'external_token'
use2FA <Bool> - Whether the user uses two-factor authentication.
walletId <String> optional - The user's wallet ID.
userStatus: <WepinUserStatus> optional - The user's status of wepin login. including:
loginStatus: <WepinLoginStatus> - 'complete' | 'pinRequired' | 'registerRequired' - If the user's loginStatus value is not complete, it must be registered in the wepin.
pinRequired: optional
token: <WepinToken> optional - The user's token of wepin.
refresh: <String>
access <String>
Exception
Example
logoutWepin
This method logs out the user logged into Wepin.
Parameters
void
Returns
<Bool>
Exception
Example
getSignForLogin
Generates signatures to verify the issuer. It is mainly used to generate signatures for login-related information such as ID tokens and access tokens.
Parameters
privKey
<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 authentication key (privKey
) must be stored securely and must not be exposed to the outside. It is recommended to execute the getSignForLogin()
method on the backend rather than the frontend for enhanced security and protection of sensitive information.
Example
finalize
This method finalizes the Wepin Login Library.
Parameters
void
Returns
void
Example
WepinLoginError
Error | Error Description |
---|---|
| One or more parameters provided are invalid or missing. |
| The WepinLoginLibrary has not been properly initialized. |
| The Wepin app key is invalid. |
| The login provider specified is not supported or is invalid. |
| The token does not exist. |
| The login session information does not exist. |
| The user has cancelled the operation. |
| An unknown error has occurred, and the cause is not identified. |
| The system is unable to detect an active internet connection. |
| The login attempt has failed due to incorrect credentials or other issues. |
| The user is already logged out, so the logout operation cannot be performed again. |
| The WepinLoginLibrary is already initialized, so the logout operation cannot be performed again. |
| The provided email address's domain is not allowed or recognized by the system. |
| 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 is required to proceed with the requested operation. |
| The provided email address does not match the expected format. |
| The provided password does not meet the required format or criteria. |
| The network or connection required for the operation has not been properly initialized. |
| The user needs to sign up with an email address to proceed. |
| The WepinLoginLibrary encountered an issue while attempting to verify the provided email address. |
| The WepinLoginLibrary failed to set state of the password. |
| The WepinLoginLibrary failed to set the password. |
| The provided email address is already registered in Wepin. |
Last updated