Skip to main content

Plug n Play Web3Auth on Native Android (Java, OpenLogin)


This tutorial will guide you to use openlogin-android-sdk to integrate Web3Auth into your Android application. OpenLogin is Web3Auth's hosted auth solution.

Source code of the example can also be found in the repository.


Android API version 21 or newer.


Add OpenLogin to Gradle

In your project-level build.gradle file, add JitPack repository:

allprojects {
repositories {
// ...
maven { url "" }

Then, in your app-level build.gradle dependencies section, add the following:

dependencies {
// ...
implementation 'org.torusresearch:openlogin-android-sdk:-SNAPSHOT'

Note: This SDK is currently in beta, using -SNAPSHOT to make sure you receive latest updates and be aware that there may be breaking changes.


Open your app's AndroidManifest.xml file and add the following permission:

<uses-permission android:name="android.permission.INTERNET" />


Configure an Plug n Play project

Go to Developer Dashboard, create or select an Plug n Play project:

  • Add {YOUR_APP_PACKAGE_NAME}://auth to Whitelist URLs.

  • Copy the Project ID for usage later.

Open your app's AndroidManifest.xml file and add the following deep link intent filter to your sign-in activity:

<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<!-- Accept URIs: {YOUR_APP_PACKAGE_NAME}://* -->
<data android:scheme="{YOUR_APP_PACKAGE_NAME}" />

Initialize OpenLogin

In your sign-in activity', create an OpenLogin instance with your OpenLogin project's configurations and configure it like this:

class MainActivity : AppCompatActivity() {
// ...
lateinit var openlogin: OpenLogin

override fun onCreate(savedInstanceState: Bundle?) {

openlogin = OpenLogin(
clientId = getString(R.string.openlogin_client_id),
network = OpenLogin.Network.MAINNET,
redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"),

// Handle user signing in when app is not alive

// ...

override fun onNewIntent(intent: Intent?) {

// Handle user signing in when app is active

// ...

private fun onClickLogin() {


Make sure your sign-in activity launchMode is set to singleTop in your AndroidManifest.xml:

// ...

API Reference

class OpenLogin(
context: Context, // Android context to launch Web-based authentication, usually is the current activity
clientId: String, // Your OpenLogin project ID
network: Network, // Network to run OpenLogin, either MAINNET or TESTNET
redirectUrl: Uri? = null, // URL that OpenLogin will redirect API responses
// Trigger login flow that shows a modal for user to select one of supported providers to login,
// e.g. Google, Facebook, Twitter, Passwordless, etc
fun login() {}

// Trigger login flow using a specific provider
fun login(
loginProvider: Provider,
) {}