# Methods

## **loginWithOauthProvider**

```dart
await wepinLogin.loginWithOauthProvider({required String provider, required String clientId})
```

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**

* [**WepinError**](#wepinerror)

#### **Example**

```dart
final user = await wepinLogin.loginWithOauthProvider(
  provider: "google",
  clientId: "your-google-client-id"
);
```

***

## **signUpWithEmailAndPassword**

```dart
await wepinLogin.signUpWithEmailAndPassword({required String email, required String password, String? locale})
```

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 [loginWepinWithEmailAndPassword](#loginwepinwithemailandpassword). Upon successful login, Firebase login information is returned.

{% hint style="info" %}
In the Flutter SDK, you can use the [`loginWepinWithEmailAndPassword`](#loginwepinwithemailandpassword) method, which combines the [`loginWithEmailAndPassword`](#loginwithemailandpassword) and [`loginWepin`](#loginwepin) methods.
{% endhint %}

#### **Parameters**

* **email** `<String>`

  User email
* **password** `<String>`

  User password
* **locale** `<String>` ***optional***

  Language 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**

* [**WepinError**](#wepinerror)

#### **Example**

```dart
final user = await wepinLogin.signUpWithEmailAndPassword(
  email: 'abc@defg.com', 
  password: 'abcdef123&'
);
```

***

## **loginWithEmailAndPassword**

```dart
await wepinLogin.loginWithEmailAndPassword({required String email, required String password})
```

Logs in to Wepin Firebase using an email and password. If the login is successful, it returns Firebase login information.

#### **Parameters**

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

* [**WepinError**](#wepinerror)

#### **Example**

```dart
final user = await wepinLogin.loginWithEmailAndPassword(
  email: 'abc@defg.com', 
  password: 'abcdef123&'
);
```

***

## **loginWithIdToken**

```dart
await wepinLogin.loginWithIdToken({required String idToken, required String sign})
```

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

  <div data-gb-custom-block data-tag="hint" data-style="warning" class="hint hint-warning"><p>Starting from <code>wepin_flutter_login_lib</code> version <mark style="color:red;">0.0.5</mark>, the <code>sign</code> value is optional.<br><br>If you choose to remove the authentication key issued from the <a href="https://workspace.wepin.io/">Wepin Workspace</a>, you may opt not to use the <code>sign</code>value.<br>(Wepin Workspace > Development Tools menu > Login tab > Auth Key > Delete)</p><blockquote><p><mark style="background-color:yellow;">The Auth Key menu is visible only if an authentication key was previously generated.</mark></p></blockquote></div>

#### **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**

* [**WepinError**](#wepinerror)

#### **Example**

```dart
final user = await wepinLogin.loginWithIdToken(
    idToken:'eyJHGciO....adQssw5c', 
    sign:'9753d4dc...c63466b9'
);
```

***

## **loginWithAccessToken**

```dart
await wepinLogin.loginWithAccessToken({required String provider, required String accessToken, required String sign})
```

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>` ***optional***

  Signature value for the Access token (returned value of [`getSignForLogin()`](#getsignforlogin))<br>

  <div data-gb-custom-block data-tag="hint" data-style="warning" class="hint hint-warning"><p>Starting from <code>wepin_flutter_login_lib</code> version <mark style="color:red;">0.0.5</mark>, the <code>sign</code> value is optional.<br><br>If you choose to remove the authentication key issued from the <a href="https://workspace.wepin.io/">Wepin Workspace</a>, you may opt not to use the <code>sign</code>value.</p><p>(Wepin Workspace > Development Tools menu > Login tab > Auth Key > Delete)</p><blockquote><p><mark style="background-color:yellow;">The Auth Key menu is visible only if an authentication key was previously generated.</mark></p></blockquote></div>

#### **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**

* [**WepinError**](#wepinerror)

#### **Example**

```dart
final user = await wepinLogin.loginWithAccessToken(
    provider: 'naver', 
    accessToken:'eyJHGciO....adQssw5c', 
    sign:'9753d4dc...c63466b9'
);
```

***

## **getRefreshFirebaseToken**

```dart
await wepinLogin.getRefreshFirebaseToken({LoginResult? prevToken})
```

Retrieves information on the current Wepin Firebase token.

#### **Parameters** (Supported from version<mark style="color:orange;">**`0.0.11`**</mark> and later.)

* prevToken \<LoginResult>  ***optional***&#x20;
  * The previous login result containing token information, which can be used for refreshing.

{% hint style="warning" %}
The **prevToken** parameter has been supported since version 0.0.11.

* If no parameter is provided, the stored token will be used to refresh and update storage. This option is only available if the Wepin login session has not expired.
* If a **prevToken** parameter is provided, the passed token will be used to refresh regardless of the Wepin login session’s expiration status.
  {% endhint %}

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

#### **Exception**

* [**WepinError**](#wepinerror)

#### **Example**

```dart
final user = await wepinLogin.getRefreshFirebaseToken({LoginResult? prevToken});
```

***

## loginFirebaseWithOauthProvider &#x20;

```dart
await wepinLogin.loginFirebaseWithOauthProvider({required String provider, required String clientId})
```

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.

{% hint style="warning" %}
This method can only be used after the authentication key has been deleted from the [Wepin Workspace](https://workspace.wepin.io/).&#x20;

(Wepin Workspace > Development Tools menu > Login tab > Auth Key > Delete)

> <mark style="background-color:yellow;">The Auth Key menu is visible only if an authentication key was previously generated.</mark>
> {% endhint %}

**Supported Version**\
Supported from version<mark style="color:orange;">**`0.0.5`**</mark> 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 token
      * **refreshToken** `<String>`\
        Wepin Firebase refresh token

**Exception**

* [WepinError](#wepinerror)

#### **Example**

```dart
final user = await wepinLogin.loginFirebaseWithOauthProvider(
    provider:'apple', 
    clietId:'apple-client-id'
);
```

## loginWepinWithOauthProvider

```dart
await wepinLogin.loginWepinWithOauthProvider({required String provider, required String clientId})
```

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.

{% hint style="warning" %}
This method can only be used after the authentication key has been deleted from the [Wepin Workspace](https://workspace.wepin.io/).

(Wepin Workspace > Development Tools menu > Login tab > Auth Key > Delete)

> <mark style="background-color:yellow;">The Auth Key menu is visible only if an authentication key was previously generated.</mark>
> {% endhint %}

**Supported Version**\
Supported from version<mark style="color:orange;">**`0.0.5`**</mark> 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>`***optional***&#x20;

      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**

```dart
final userInfo = await wepinLogin.loginWepinWithOauthProvider(
  provider: 'google',
  clientId; 'google-client-id'
);

final userStatus = userInfo.userStatus;
if (userStatus.loginStatus == 'pinRequired' || userStatus.loginStatus == 'registerRequired') {
    // Wepin register
}
```

## loginWepinWithIdToken

```dart
await wepinLogin.loginWepinWithIdToken({required String idToken, String? sign})
```

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 version<mark style="color:orange;">**`0.0.5`**</mark> and later.

#### **Parameters**

* **idToken** `<String>`\
  The ID token 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="warning" %}
If you choose to remove the authentication key issued from the [Wepin Workspace](https://workspace.wepin.io/), you may opt not to use the `sign`value.

(Wepin Workspace > Development Tools menu > Login tab > Auth Key > Delete)

> <mark style="background-color:yellow;">The Auth Key menu is visible only if an authentication key was previously generated.</mark>
> {% endhint %}

#### **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>`***optional***&#x20;

      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**

```dart
final userInfo = await wepinLogin.loginWepinWithIdToken(
  idToken:'eyJHGciO....adQssw5c',
);

final userStatus = userInfo.userStatus;
if (userStatus.loginStatus == 'pinRequired' || userStatus.loginStatus == 'registerRequired') {
    // Wepin register
}
```

## loginWepinWithAccessToken

```dart
await wepinLogin.loginWepinWithAccessToken({required String provider, required String accessToken, String? sign})
```

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 version<mark style="color:orange;">**`0.0.5`**</mark> and later.

#### **Parameters**

* **provider** `<"naver"|"discord">`

  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))<br>

  <div data-gb-custom-block data-tag="hint" data-style="warning" class="hint hint-warning"><p>If you choose to remove the authentication key issued from the <a href="https://workspace.wepin.io/">Wepin Workspace</a>, you may opt not to use the <code>sign</code>value.</p><p>(Wepin Workspace > Development Tools menu > Login tab > Auth Key > Delete)</p><blockquote><p><mark style="background-color:yellow;">The Auth Key menu is visible only if an authentication key was previously generated.</mark></p></blockquote></div>

#### **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>`***optional***&#x20;

      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**

```dart
final userInfo = await wepinLogin.loginWepinWithAccessToken(
    provider: 'naver',
    accessToken:'eyJHGciO....adQssw5c',
);

final userStatus = userInfo.userStatus;
if (userStatus.loginStatus == 'pinRequired' || userStatus.loginStatus == 'registerRequired') {
    // Wepin register
}
```

## loginWepinWithEmailAndPassword

```dart
await wepinLogin.loginWepinWithEmailAndPassword({required String email, required String password})
```

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 version<mark style="color:orange;">**`0.0.5`**</mark> 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 Wepin
    * **pinRequired** `<bool>`***optional***&#x20;

      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**

```dart
final userInfo = await wepinLogin.loginWithEmailAndPassword(
    email: "abc@abc.com",
    password: "user_password"
);

final userStatus = userInfo.userStatus;
if (userStatus.loginStatus == 'pinRequired' || userStatus.loginStatus == 'registerRequired') {
    // Wepin register
}
```

## **loginWepin**

```dart
await wepinLogin.loginWepin(LoginResult params)
```

Logs the user into Wepin using the Wepin Firebase token.

#### **Parameters**

* **params** `<LoginResult>`\
  Parameters from the return value of methods like `loginWithEmailAndPassword()`, `loginWithIdToken()`, or `loginWithAccessToken()`.

#### **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>`***optional***&#x20;

      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**

```dart
final wepinLogin = WepinLogin(appId: 'appId', appKey: 'appKey');
await wepinLogin.init();
final res = await wepinLogin.loginWithOauthProvider(
    provider: "google",
    clientId: "your-google-client-id"
);

final sign = wepinLogin?.getSignForLogin(privateKey: privateKey, message: res!.token);
LoginResult? resLogin;
if(provider == 'naver' || provider == 'discord') {
  resLogin = await wepinLogin.loginWithAccessToken(provider: provider, accessToken: res!.token, sign: sign));
} else {
  resLogin = await wepinLogin.loginWithIdToken(idToken: res!.token, sign: sign));
}

final userInfo = await wepinLogin.loginWepin(resLogin);
final userStatus = userInfo.userStatus;
if (userStatus.loginStatus == 'pinRequired' || userStatus.loginStatus == 'registerRequired') {
    // Wepin register
}
```

***

## **getCurrentWepinUser**

```dart
await wepinLogin.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 Wepin
    * **pinRequired** `<bool>`***optional***&#x20;

      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**

```dart
final userInfo = await wepinLogin.getCurrentWepinUser();
final userStatus = userInfo.userStatus;
if (userStatus.loginStatus == 'pinRequired' || userStatus.loginStatus == 'registerRequired') {
    // Wepin register
}
```

***

## **logout**

```dart
await wepinLogin.logout()
```

Logs out the currently logged-in user from Wepin.

#### **Parameters**

* **None**

#### **Returns**

* **Future\<bool>**

#### **Exception**

* [**WepinError**](#wepinerror)

#### **Example**

```dart
final result = await wepinLogin.logout();
if (result) {
  // Successfully logged out
}
```

***

## **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.

```dart
final result = getSignForLogin({required String privateKey, required String message});
```

#### **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:

* [Signature Generation Methods](https://github.com/WepinWallet/wepin-web-sdk-v1/blob/main/packages/login/SignatureGenerationMethods.md)
  {% endhint %}

#### **Example**

```dart
final sign = getSignForLogin(
  privateKey: '0400112233445566778899001122334455667788990011223344556677889900', 
  message: 'idtokenabcdef'
);

final res = await wepinLogin.loginWithIdToken(
    idToken: 'eyJHGciO....adQssw5c', 
    sign: sign
);
```

***

## **finalize**

```dart
await wepinLogin.finalize()
```

Terminates the Wepin Login Library.

#### **Parameters**

* **None**

#### **Returns**

* **Future\<void>** \
  A Future that resolves when the finalization process is complete.

#### **Example**

```dart
await wepinLogin.finalize();
```

## WepinError

| Error Code                    | Error Message                 | Error Description                                                                                                                                                                                    |
| ----------------------------- | ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `invalidAppKey`               | "InvalidAppKey"               | The Wepin app key is invalid.                                                                                                                                                                        |
| `invalidParameters` \`        | "InvalidParameters"           | One or more parameters provided are invalid or missing.                                                                                                                                              |
| `invalidLoginProvider`        | "InvalidLoginProvider"        | The login provider specified is not supported or is invalid.                                                                                                                                         |
| `invalidToken`                | "InvalidToken"                | The token does not exist.                                                                                                                                                                            |
| `invalidLoginSession`         | "InvalidLoginSession"         | The login session information does not exist.                                                                                                                                                        |
| `notInitialized`              | "NotInitialized"              | The WepinLoginLibrary has not been properly initialized.                                                                                                                                             |
| `alreadyInitialized`          | "AlreadyInitialized"          | The WepinLoginLibrary is already initialized, so the logout operation cannot be performed again.                                                                                                     |
| `userCancelled`               | "UserCancelled"               | The user has cancelled the operation.                                                                                                                                                                |
| `unknownError`                | "UnknownError"                | An unknown error has occurred, and the cause is not identified.                                                                                                                                      |
| `notConnectedInternet`        | "NotConnectedInternet"        | The system is unable to detect an active internet connection.                                                                                                                                        |
| `failedLogin`                 | "FailedLogin"                 | The login attempt has failed due to incorrect credentials or other issues.                                                                                                                           |
| `alreadyLogout`               | "AlreadyLogout"               | The user is already logged out, so the logout operation cannot be performed again.                                                                                                                   |
| `invalidEmailDomain`          | "InvalidEmailDomain"          | The provided email address's domain is not allowed or recognized by the system.                                                                                                                      |
| `failedSendEmail`             | "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`       | "RequiredEmailVerified"       | Email verification is required to proceed with the requested operation.                                                                                                                              |
| `incorrectEmailForm`          | "incorrectEmailForm"          | The provided email address does not match the expected format.                                                                                                                                       |
| `incorrectPasswordForm`       | "IncorrectPasswordForm"       | The provided password does not meet the required format or criteria.                                                                                                                                 |
| `notInitializedNetwork`       | "NotInitializedNetwork"       | The network or connection required for the operation has not been properly initialized.                                                                                                              |
| `requiredSignupEmail`         | "RequiredSignupEmail"         | The user needs to sign up with an email address to proceed.                                                                                                                                          |
| `failedEmailVerified`         | "FailedEmailVerified"         | The WepinLoginLibrary encountered an issue while attempting to verify the provided email address.                                                                                                    |
| `failedPasswordStateSetting`  | "FailedPasswordStateSetting"  | Failed to set the password state. This error may occur during password management operations, potentially due to invalid input or system issues.                                                     |
| `failedPasswordSetting`       | "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`                | "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`             | "ApiRequestError"             | There was an error while making the API request. This can happen due to network issues, invalid endpoints, or server errors.                                                                         |
| `incorrectLifecycleException` | "IncorrectLifecycleException" | The lifecycle of the Wepin SDK is incorrect for the requested operation. Ensure that the SDK is in the correct state (e.g., `initialized` and `login`) before proceeding.                            |
| `failedRegister`              | "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`             | "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`                 | "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`                  | "FailedSend"                  | Failed to send the required data or request. This error could be due to network issues, incorrect data, or internal server errors.                                                                   |
