# Logging in a user

> Web3Auth Android SDK - Login Function | Embedded Wallets

To login in a user, you can use the `login` method. It will trigger login flow will navigate the user to a browser model allowing the user to login into the service. You can pass in the supported providers to the login method for specific social logins (such as GOOGLE, APPLE, FACEBOOK) and do whitelabel login.

## Parameters

The `login` method takes in `LoginParams` as a required input.

<Tabs
  defaultValue="table"
  values={[
    { label: "Table", value: "table" },
    { label: "Class", value: "class" },
  ]}
>

<TabItem value="table">

| Parameter            | Description                                                                                                                                                                                                                                                                                                                                                             |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `loginProvider`      | It sets the OAuth login method to be used. You can use any of the supported values are `GOOGLE`, `FACEBOOK`, `REDDIT`, `DISCORD`, `TWITCH`, `APPLE`, `LINE`, `GITHUB`, `KAKAO`, `LINKEDIN`, `TWITTER`, `WEIBO`, `WECHAT`, `EMAIL_PASSWORDLESS`, `JWT`, `SMS_PASSWORDLESS`, and `FARCASTER`.                                                                             |
| `extraLoginOptions?` | It can be used to set the OAuth login options for corresponding `loginProvider`. For instance, you'll need to pass user's email address as. Default value for the field is `null`, and it accepts `ExtraLoginOptions` as a value.                                                                                                                                       |
| `redirectUrl?`       | URL where user will be redirected after successfull login. By default user will be redirected to same page where login will be initiated. Default value for the field is `null`, and accepts `Uri` as a value.                                                                                                                                                          |
| `appState?`          | It can be used to keep track of the app state when user will be redirected to app after login. Default is `null`, and accepts a string value.                                                                                                                                                                                                                           |
| `mfaLevel?`          | Customize the MFA screen shown to the user during OAuth authentication. Default value for field is `MFALevel.DEFAULT`, which shows MFA screen every 3rd login. It accepts `MFALevel` as a value.                                                                                                                                                                        |
| `dappShare?`         | Custom verifier logins can get a dapp share returned to them post successful login. This is useful if the dapps want to use this share to allow users to login seamlessly. It accepts a string value.                                                                                                                                                                   |
| `curve?`             | It will be used to determine the public key encoded in the JWT token which returned in `getUserInfo` function after user login. This parameter won't change format of private key returned by We3Auth. Private key returned by `getPrivKey` is always secp256k1. To get the ed25519 key you can use `getEd25519PrivKey` method. The default value is `Curve.SECP256K1`. |

</TabItem>

<TabItem value="class">

```kotlin
data class LoginParams(
    val loginProvider: Provider,
    var dappShare: String? = null,
    val extraLoginOptions: ExtraLoginOptions? = null,
    @Transient var redirectUrl: Uri? = null,
    val appState: String? = null,
    val mfaLevel: MFALevel? = null,
    val curve: Curve? = Curve.SECP256K1
)

enum class Provider {
    @SerializedName("google")
    GOOGLE,
    @SerializedName("facebook")
    FACEBOOK,
    @SerializedName("reddit")
    REDDIT,
    @SerializedName("discord")
    DISCORD,
    @SerializedName("twitch")
    TWITCH,
    @SerializedName("apple")
    APPLE,
    @SerializedName("line")
    LINE,
    @SerializedName("github")
    GITHUB,
    @SerializedName("kakao")
    KAKAO,
    @SerializedName("linkedin")
    LINKEDIN,
    @SerializedName("twitter")
    TWITTER,
    @SerializedName("weibo")
    WEIBO,
    @SerializedName("wechat")
    WECHAT,
    @SerializedName("email_passwordless")
    EMAIL_PASSWORDLESS,
    @SerializedName("jwt")
    JWT,
    @SerializedName("sms_passwordless")
    SMS_PASSWORDLESS,
    @SerializedName("farcaster")
    FARCASTER
}
```

</TabItem>
</Tabs>

## Usage

```kotlin

val web3Auth = Web3Auth(
  Web3AuthOptions(
    context = this,
    clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass your Web3Auth Client ID, ideally using an environment variable
    network = Network.MAINNET,
    redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"),
  )
)

// focus-start
val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.login(
    LoginParams(Provider.GOOGLE)
)
// focus-end
```

## Examples

<Tabs
  defaultValue="google"
  values={[
    { label: "Google", value: "google" },
    { label: "Facebook", value: "facebook" },
    { label: "Discord", value: "discord" },
    { label: "Twitch", value: "twitch" },
    { label: "Email Passwordless", value: "email_passwordless" },
    { label: "SMS Passwordless", value: "sms_passwordless" },
    { label: "Farcaster", value: "farcaster" },
    { label: "JWT", value: "jwt" },
  ]}
>

<TabItem value="google">

```kotlin

val web3Auth = Web3Auth(
  Web3AuthOptions(
    context = this,
    clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass your Web3Auth Client ID, ideally using an environment variable
    network = Network.MAINNET,
    redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"),
  )
)

// focus-start
val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.login(
    LoginParams(Provider.GOOGLE)
)
// focus-end
```

</TabItem>

<TabItem value="facebook">

```kotlin

val web3Auth = Web3Auth(
  Web3AuthOptions(
    context = this,
    clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass your Web3Auth Client ID, ideally using an environment variable
    network = Network.MAINNET,
    redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"),
  )
)

// focus-start
val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.login(
    LoginParams(Provider.FACEBOOK)
)
// focus-end
```

</TabItem>

<TabItem value="discord">

```kotlin

val web3Auth = Web3Auth(
  Web3AuthOptions(
    context = this,
    clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass your Web3Auth Client ID, ideally using an environment variable
    network = Network.MAINNET,
    redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"),
  )
)

// focus-start
val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.login(
    LoginParams(Provider.DISCORD)
)
// focus-end
```

</TabItem>

<TabItem value="twitch">

```kotlin

val web3Auth = Web3Auth(
  Web3AuthOptions(
    context = this,
    clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass your Web3Auth Client ID, ideally using an environment variable
    network = Network.MAINNET,
    redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"),
  )
)

// focus-start
val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.login(
    LoginParams(Provider.TWITCH)
)
// focus-end
```

</TabItem>

<TabItem value="email_passwordless">

```kotlin

val web3Auth = Web3Auth(
  Web3AuthOptions(
    context = this,
    clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass your Web3Auth Client ID, ideally using an environment variable
    network = Network.MAINNET,
    redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"),
  )
)

// focus-start
val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.login(
    LoginParams(
        Provider.EMAIL_PASSWORDLESS,
        extraLoginOptions = ExtraLoginOptions(login_hint = "hello@web3auth.io")
    )
)
// focus-end
```

</TabItem>

<TabItem value="sms_passwordless">
```kotlin

val web3Auth = Web3Auth( Web3AuthOptions( context = this, clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass your Web3Auth Client ID, ideally using an environment variable network = Network.MAINNET, redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"), ) )

// focus-start val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.login( LoginParams( Provider.SMS_PASSWORDLESS, extraLoginOptions = ExtraLoginOptions(login_hint = "+91-9911223344") ) ) // focus-end

````

</TabItem>

<TabItem value="farcaster">

```kotlin

val web3Auth = Web3Auth(
  Web3AuthOptions(
    context = this,
    clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass your Web3Auth Client ID, ideally using an environment variable
    network = Network.MAINNET,
    redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"),
  )
)

// focus-start
val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.login(
  LoginParams(Provider.Farcaster)
)
// focus-end
````

</TabItem>

<TabItem value="jwt">

```kotlin title="Usage"

val web3Auth = Web3Auth(
  Web3AuthOptions(
    context = this,
    clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass your Web3Auth Client ID, ideally using an environment variable
    network = Network.MAINNET,
    redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"),
  )
)

// focus-start
val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.login(
    LoginParams(
        Provider.JWT,
        extraLoginOptions = ExtraLoginOptions(id_token = "<your_jwt_token>")
    )
)
// focus-end
```

</TabItem>
</Tabs>
