Web3Auth is where passwordless auth meets non-custodial key infrastructure for Web3 apps and wallets. By aggregating OAuth (Google, Twitter, Discord) logins, different wallets and innovative Multi Party Computation (MPC) - Web3Auth provides a seamless login experience to every user on your application.
Checkout the official Web3Auth Documentation and SDK Reference to get started!
- Plug and Play, OAuth based Web3 Authentication Service
- Fully decentralized, non-custodial key infrastructure
- End to end Whitelabelable solution
- Threshold Cryptography based Key Reconstruction
- Multi Factor Authentication Setup & Recovery (Includes password, backup phrase, device factor editing/deletion etc)
- Support for WebAuthn & Passwordless Login
- Support for connecting to multiple wallets
- DApp Active Session Management
...and a lot more
- Android API version 24 or newer is required.
In your project-level settings.gradle
file, add JitPack repository:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" } // <-- Add this line
}
}
Then, in your app-level build.gradle
dependencies section, add the following:
dependencies {
// ...
implementation 'org.torusresearch:web3auth-android-sdk:-SNAPSHOT'
}
Open your app's AndroidManifest.xml
file and add the following permission:
<uses-permission android:name="android.permission.INTERNET" />
Hop on to the Web3Auth Dashboard and create a new project. Use the Client ID of the project to start your integration.
-
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:
<intent-filter>
<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}" />
</intent-filter>
Make sure your sign-in activity launchMode is set to singleTop in your AndroidManifest.xml
<activity
android:launchMode="singleTop"
android:name=".YourActivity">
// ...
</activity>
In your sign-in activity', create an Web3Auth
instance with your Web3Auth project's configurations and
configure it like this:
class MainActivity : AppCompatActivity() {
// ...
private lateinit var web3Auth: Web3Auth
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
web3Auth = Web3Auth(
Web3AuthOptions(context = this,
clientId = getString(R.string.web3auth_project_id),
network = Web3Auth.Network.MAINNET,
redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"),
whiteLabel = WhiteLabelData( // Optional param
"Web3Auth Sample App", null, null, "en", true,
hashMapOf(
"primary" to "#123456"
)
)
)
)
// Handle user signing in when app is not alive
web3Auth.setResultUrl(intent?.data)
// Call initialize function to get private key and user information value without relogging in user if a user has an active session
val sessionResponse: CompletableFuture<Void> = web3Auth.initialize()
sessionResponse.whenComplete { _, error ->
if (error == null) {
println("PrivKey: " + web3Auth.getPrivkey())
println("ed25519PrivKey: " + web3Auth.getEd25519PrivKey())
println("Web3Auth UserInfo" + web3Auth.getUserInfo())
} else {
// render error UI
}
}
// ...
}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
// Handle user signing in when app is active
web3Auth.setResultUrl(intent?.data)
// ...
}
private fun onClickLogin() {
val selectedLoginProvider = Provider.GOOGLE // Can be Google, Facebook, Twitch etc
val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.login(LoginParams(selectedLoginProvider))
loginCompletableFuture.whenComplete { _, error ->
if (error == null) {
// render logged in UI
println("PrivKey: " + web3Auth.getPrivkey())
println("ed25519PrivKey: " + web3Auth.getEd25519PrivKey())
println("Web3Auth UserInfo" + web3Auth.getUserInfo())
} else {
// render login error UI
}
}
}
//...
}
Checkout the examples for your preferred blockchain and platform in our examples
Checkout the Web3Auth Demo to see how Web3Auth can be used in an application.
Further checkout the app folder within this repository, which contains a sample app.
- Have a look at our Community Portal to see if anyone has any questions or issues you might be having. Feel free to reate new topics and we'll help you out as soon as possible.
- Checkout our Troubleshooting Documentation Page to know the common issues and solutions.
- For Priority Support, please have a look at our Pricing Page for the plan that suits your needs.