# Methods

## loginWithOauthProvider

```kotlin
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 Provider
  * **clientId** `<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**

* [WepinError](#wepinerror)

**Example**

<pre class="language-kotlin"><code class="lang-kotlin"><strong>coroutineScope.launch { 
</strong>    wepinLogin.loginWithOauthProvider(LoginOauth2Params(
        provider = "google",
        clientId = "your-google-client-id",
    ))
}
</code></pre>

## signUpWithEmailAndPassword

```kotlin
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](#loginwithemailandpassword). Upon successful login, Firebase login information is returned.

**Parameters**

* **params** `<LoginWithEmailParams>`
  * **email** `<String>`\
    User email
  * **password** `<String>`\
    User password
  * **locale** `<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 token
    * **refreshToken** `<String>`\
      The Wepin Firebase refresh token

**Exception**

* [WepinError](#wepinerror)

**Example**

```kotlin
coroutineScope.launch { 
    wepinLogin.signUpWithEmailAndPassword(
        LoginWithEmailParams(
            email = "abc@defg.com", 
            password = "abcdef123$"
        )
    )
}
```

## loginWithEmailAndPassword

<pre class="language-kotlin"><code class="lang-kotlin"><strong>suspend fun loginWithEmailAndPassword(params: LoginWithEmailParams): LoginResult
</strong></code></pre>

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 email
  * **password** `<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 token
    * **refreshToken** `<String>`\
      The Wepin Firebase refresh token

**Exception**

* [WepinError](#wepinerror)

**Example**

```kotlin
coroutineScope.launch { 
    wepinLogin.loginWithEmailAndPassword(
        LoginWithEmailParams(
            email = "abc@defg.com", 
            password = "abcdef123$"
        )
    )
}
```

## loginWithIdToken

<pre class="language-kotlin"><code class="lang-kotlin"><strong>suspend fun loginWithIdToken(params: LoginOauthIdTokenRequest): LoginResult
</strong></code></pre>

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 login
  * **sign** `<String>` (*optional*)\
    Signature value for the token provided as the first parameter (returned value of   [`getSignForLogin()`](#getsignforlogin))

{% hint style="info" %}
Starting from wepin-compose-sdk-login-v1 version 0.0.10, the sign value is optional. If you choose to remove the authentication key issued from the [Wepin Workspace](https://workspace.wepin.io/) (Wepin Workspace > Developer Tools menu > Login tab > Auth Key > Delete), you may opt not to use the `sign` value. The Auth Key menu is visible only if an authentication key was previously generated.
{% endhint %}

**Returns**

* **\<LoginResult>**
  * **provider** `<Providers.EXTERNAL_TOKEN>`\
    The provider used for the login
  * **token** `<FBToken>`
    * **idToken** `<String>`\
      The Wepin Firebase ID token
    * **refreshToken** `<String>`\
      The Wepin Firebase refresh token

**Exception**

* [WepinError](#wepinerror)

**Example**

```kotlin
  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

```kotlin
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*)\
    Signature value for the Access token (returned value of [`getSignForLogin()`](#getsignforlogin)).

{% hint style="info" %}
Starting from wepin-compose-sdk-login-v1 version 0.0.10, the sign value is optional. If you choose to remove the authentication key issued from the [Wepin Workspace](https://workspace.wepin.io/)(Wepin Workspace > Developer Tools menu > Login tab > Auth Key > Delete), you may opt not to use the `sign` value. The Auth Key menu is visible only if an authentication key was previously generated.
{% endhint %}

**Returns**

* **\<LoginResult>**
  * **provider** `<Providers.EXTERNAL_TOKEN>`\
    The provider used for the login
  * **token** `<FBToken>`
    * **idToken** `<String>`\
      The Wepin Firebase ID token
    * **refreshToken** `<String>`\
      The Wepin Firebase refresh token

**Exception**

* [WepinError](#wepinerror)

**Example**

```kotlin
  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

```kotlin
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 login
  * **token** `<FBToken>`
    * **idToken** `<String>`\
      The Wepin Firebase ID token
    * **refreshToken** `<String>`\
      The Wepin Firebase refresh token.

**Exception**

* [WepinError](#wepinerror)

**Example**

```kotlin
coroutineScope.launch { 
    wepinLogin.getRefreshFirebaseToken()
}
```

## loginFirebaseWithOauthProvider

Supported from version *`0.0.10`* and later.

```kotlin
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 Provider
  * **clientId** `<String>`\
    The client ID of the OAuth login provider

**Returns**

* **\<LoginResult>**
  * **provider** `<Providers.EXTERNAL_TOKEN>`\
    The provider used for the login
  * **token** `<FBToken>`
    * **idToken** `<String>`\
      The Wepin Firebase ID token
    * **refreshToken** `<String>`\
      The Wepin Firebase refresh token.

**Exception**

* [WepinError](#wepinerror)

**Example**

```kotlin
  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.

```kotlin
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.

{% hint style="info" %}
This method can only be used after the authentication key has been deleted from the [Wepin Workspace](https://workspace.wepin.io/)(Wepin Workspace > Developer Tools menu > Login tab > Auth Key > Delete). The Auth Key menu is visible only if an authentication key was previously generated.
{% endhint %}

**Parameters**

* **params** `<`LoginOauth2Params`>`
  * **provider** `<'google'|'naver'|'discord'|'apple'>`\
    The OAuth login Provider
  * **clientId** `<String>`\
    The client ID of the OAuth login provider

**Returns**

* **\<WepinUser>** (*optional*)
  * **status** `<'success' | 'fail'>`\
    The login status
  * **userInfo** `<UserInfo>` (*optional*)\
    The user's information, including:
    * **userId** `<String>`\
      The user's ID
    * **email** `<String>`\
      The user's email
    * **provider** `<'google'|'naver'|'discord'|'apple'|'email' | 'external_token'>`\
      The login provider
    * **use2FA** `<Boolean>`\
      Whether the user uses two-factor authentication
  * **walletId** `<String>`\
    The user's wallet ID
  * **userStatus** `<UserStatus>` (*optional*)\
    The user's Wepin login status, including:
    * **loginStatus** `<WepinLoginStatus - 'complete' | 'pinRequired' | 'registerRequired'>`\
      If the user's `loginStatus` value is not 'complete', the user must register with Wepin.
    * **pinRequired** `<Boolean>`\
      Whether a PIN is required
  * **token** `<Token>`\
    The user's Wepin token
    * **accessToken** `<String>`\
      The access token
    * **refreshToken** `<String>`\
      The refresh token

**Exception**

* [WepinError](#wepinerror)

**Example**

```kotlin
  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.

```kotlin
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 email
  * **password** `<String>`\
    User password

**Returns**

* **\<WepinUser>** (*optional*)
  * **status** `<'success' | 'fail'>`\
    The login status
  * **userInfo** `<UserInfo>` (*optional*)\
    The user's information, including:
    * **userId** `<String>`\
      The user's ID
    * **email** `<String>`\
      The user's email
    * **provider** `<'google'|'naver'|'discord'|'apple'|'email' | 'external_token'>`\
      The login provider
    * **use2FA** `<Boolean>`\
      Whether the user uses two-factor authentication
  * **walletId** `<String>`\
    The user's wallet ID
  * **userStatus** `<UserStatus>` (*optional*)\
    The user's Wepin login status, including:
    * **loginStatus** `<WepinLoginStatus - 'complete' | 'pinRequired' | 'registerRequired'>`\
      If the user's `loginStatus` value is not 'complete', the user must register with Wepin.
    * **pinRequired** `<Boolean>`\
      Whether a PIN is required
  * **token** `<Token>`\
    The user's Wepin token
    * **accessToken** `<String>`\
      The access token
    * **refreshToken** `<String>`\
      The refresh token

**Exception**

* [WepinError](#wepinerror)

**Example**

```kotlin
  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.

```kotlin
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 login
  * **sign** `<String>` (*optional*)\
    Signature value for the token provided as the first parameter (returned value of   [`getSignForLogin()`](#getsignforlogin))

{% hint style="info" %}
Starting from wepin-compose-sdk-login-v1 version 0.0.10, the sign value is optional. If you choose to remove the authentication key issued from the [Wepin Workspace](https://workspace.wepin.io/)(Wepin Workspace > Developer Tools menu > Login tab > Auth Key > Delete), you may opt not to use the `sign` value. The Auth Key menu is visible only if an authentication key was previously generated.
{% endhint %}

**Returns**

* **\<WepinUser>** (*optional*)
  * **status** `<'success' | 'fail'>`\
    The login status
  * **userInfo** `<UserInfo>` (*optional*)\
    The user's information, including:
    * **userId** `<String>`\
      The user's ID
    * **email** `<String>`\
      The user's email
    * **provider** `<'google'|'naver'|'discord'|'apple'|'email' | 'external_token'>`\
      The login provider
    * **use2FA** `<Boolean>`\
      Whether the user uses two-factor authentication
  * **walletId** `<String>`\
    The user's wallet ID
  * **userStatus** `<UserStatus>` (*optional*)\
    The user's Wepin login status, including:
    * **loginStatus** `<WepinLoginStatus - 'complete' | 'pinRequired' | 'registerRequired'>`\
      If the user's `loginStatus` value is not 'complete', the user must register with Wepin.
    * **pinRequired** `<Boolean>`\
      Whether a PIN is required
  * **token** `<Token>`\
    The user's Wepin token
    * **accessToken** `<String>`\
      The access token
    * **refreshToken** `<String>`\
      The refresh token

**Exception**

* [WepinError](#wepinerror)

**Example**

```kotlin
  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.

```kotlin
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*)\
    Signature value for the Access token (returned value of [`getSignForLogin()`](#getsignforlogin)).

{% hint style="info" %}
Starting from wepin-compose-sdk-login-v1 version 0.0.10, the sign value is optional. If you choose to remove the authentication key issued from the [Wepin Workspace](https://workspace.wepin.io/)(Wepin Workspace > Developer Tools menu > Login tab > Auth Key > Delete) , you may opt not to use the `sign` value. The Auth Key menu is visible only if an authentication key was previously generated.
{% endhint %}

**Returns**

* **\<WepinUser>** (*optional*)
  * **status** `<'success' | 'fail'>`\
    The login status
  * **userInfo** `<UserInfo>` (*optional*)\
    The user's information, including:
    * **userId** `<String>`\
      The user's ID
    * **email** `<String>`\
      The user's email
    * **provider** `<'google'|'naver'|'discord'|'apple'|'email' | 'external_token'>`\
      The login provider
    * **use2FA** `<Boolean>`\
      Whether the user uses two-factor authentication
  * **walletId** `<String>`\
    The user's wallet ID
  * **userStatus** `<UserStatus>` (*optional*)\
    The user's Wepin login status, including:
    * **loginStatus** `<WepinLoginStatus - 'complete' | 'pinRequired' | 'registerRequired'>`\
      If the user's `loginStatus` value is not 'complete', the user must register with Wepin.
    * **pinRequired** `<Boolean>`\
      Whether a PIN is required
  * **token** `<Token>`\
    The user's Wepin token
    * **accessToken** `<String>`\
      The access token
    * **refreshToken** `<String>`\
      The refresh token

**Exception**

* [WepinError](#wepinerror)

**Example**

```kotlin
  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

```kotlin
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 like[`loginWithEmailAndPassword()`](#loginwithemailandpassword), [`loginWithIdToken()`](#loginwithidtoken), or [`loginWithAcccessToken()`](#loginwithaccesstoken)&#x20;

**Returns**

* **\<WepinUser>** (*optional*)
  * **status** `<'success' | 'fail'>`\
    The login status
  * **userInfo** `<UserInfo>` (*optional*)\
    The user's information, including:
    * **userId** `<String>`\
      The user's ID
    * **email** `<String>`\
      The user's email
    * **provider** `<'google'|'naver'|'discord'|'apple'|'email' | 'external_token'>`\
      The login provider
    * **use2FA** `<Boolean>`\
      Whether the user uses two-factor authentication
  * **walletId** `<String>`\
    The user's wallet ID
  * **userStatus** `<UserStatus>` (*optional*)\
    The user's Wepin login status, including:
    * **loginStatus** `<WepinLoginStatus - 'complete' | 'pinRequired' | 'registerRequired'>`\
      If the user's `loginStatus` value is not 'complete', the user must register with Wepin.
    * **pinRequired** `<Boolean>`\
      Whether a PIN is required
  * **token** `<Token>`\
    The user's Wepin token
    * **accessToken** `<String>`\
      The access token
    * **refreshToken** `<String>`\
      The refresh token

**Exception**

* [WepinError](#wepinerror)

**Example**

```kotlin
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

```kotlin
suspend fun getCurrentWepinUser(): WepinUser
```

Retrieves information about the currently logged-in user in Wepin.

**Parameters**

* None

**Returns**

* **\<WepinUser>**&#x20;
  * **status** `<'success' | 'fail'>`\
    The login status
  * **userInfo** `<UserInfo>` (*optional*)\
    The user's information, including:
    * **userId** `<String>`\
      The user's ID
    * **email** `<String>`\
      The user's email
    * **provider** `<'google'|'naver'|'discord'|'apple'|'email' | 'external_token'>`\
      The login provider
    * **use2FA** `<Boolean>`\
      Whether the user uses two-factor authentication
  * **walletId** `<String>`\
    The user's wallet ID
  * **userStatus** `<UserStatus>` (*optional*)\
    The user's Wepin login status, including:
    * **loginStatus** `<WepinLoginStatus - 'complete' | 'pinRequired' | 'registerRequired'>`\
      If the user's `loginStatus` value is not 'complete', the user must register with Wepin.
    * **pinRequired** `<Boolean>`\
      Whether a PIN is required
  * **token** `<Token>`\
    The user's Wepin token
    * **accessToken** `<String>`\
      The access token
    * **refreshToken** `<String>`\
      The refresh token

**Exception**

* [WepinError](#wepinerror)

**Example**

```kotlin
coroutineScope.launch {
    val userInfo = wepinLogin.getCurrentWepinUser()
    val userStatus = userInfo.userStatus!!
    if (userStatus.loginStatus != WepinLoginStatus.COMPLETE) {
        //Wepin Register 코드..
    }
}
```

## logoutWepin

```kotlin
suspend fun logoutWepin(): Boolean
```

Logs out the currently logged-in user from Wepin.

**Parameters**

* None

**Returns**

* **\<Boolean>**

**Exception**

* [WepinError](#wepinerror)

**Example**

```kotlin
coroutineScope.launch {
    wepinLogin.logoutWepin()
}
```

## getSignForLogin

```kotlin
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 generation
* **message** `<String>`\
  The message or payload to be signed

{% hint style="info" %}
The key for signing can be obtained from [Wepin Workspace](https://workspace.wepin.io/). In the Development Tools menu, click **Get your authentication key** on the Login tab to retrieve the authentication key.
{% endhint %}

**Returns**

* **\<String>** - The generated signature

{% hint style="warning" %}
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](https://github.com/WepinWallet/wepin-web-sdk-v1/blob/main/packages/login/SignatureGenerationMethods.md).
{% endhint %}

**Exception**

* [WepinError](#wepinerror)

**Example**

```kotlin
wepinLogin.getSignForLogin(
    privateKeyHex = "private key", 
    message = "idtokenoraccesstoken"
) 
```

## finalize

```kotlin
fun finalize()
```

Terminates the Wepin Login Library.

**Parameters**

* None

**Returns**

* None

**Exception**

* [WepinError](#wepinerror)

**Example**

```kotlin
wepinLogin.finalize()
```

## Wepin Error

| Error Code                  | Error Message                     | Error Description                                                                                                                                                                                    |
| --------------------------- | --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `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.                                                                                                                                           |
