Skip to main content

Using Core Kit SFA Android SDK

After successfully installing and initializing SingleFactorAuth, you can use it to authenticate your users and obtain their private and public keys.

The SingleFactorAuth instance natively provides the following functions:

  • getKey() - Returns the torus key using the verifier, verifierId & idToken.



To obtain a user's Torus key using the Web3Auth SFA Android SDK, you can call the getKey() function.

loginParamsParameters for the login. It takes LoginParams as the value.
context?Android activity context
sessionTimesessionTime parameter is used for session management. The default value is 1 day ~ 86400, and max value is 7 days. It takes Long as a value.


public CompletableFuture<TorusKey> getKey(loginParams: LoginParams, context: Context? = null, sessionTime: Long = 86400)`

On a successful call, the getKey() function returns a CompletableFuture instance.


getKey(loginParams: LoginParams, context: Context? = null, sessionTime: Long = 86400)

verifierThe verifier obtained from the Web3Auth Dashboard. It's a mandatory field and takes String as a value.
verifierIdThe verifierId used for the verification. It takes String as a value.
idTokenThe idToken of the user obtained from the login provider. It takes String as a value.
subVerifierInfoArray?Sub verifier info. Usually used during the aggregate verifier. It takes Array<TorusSubVerifierInfo> as a value.
torusKey = singleFactorAuth.getKey(loginParams).get();

Web3Auth SFA Android SDK only works for users who have not enabled MFA.

MFA enabled users

For MFA enabled users, you'll see an Error message.


import android.widget.Button
import android.os.Bundle
import com.github.web3auth.singlefactorauth.SingleFactorAuth
import com.github.web3auth.singlefactorauth.types.SingleFactorAuthArgs
import com.github.web3auth.singlefactorauth.types.LoginParams
import com.github.web3auth.singlefactorauth.types.TorusKey
import org.torusresearch.fetchnodedetails.types.TorusNetwork

class MainActivity : AppCompatActivity() {
// ...
private lateinit var singleFactorAuth: SingleFactorAuth
private lateinit var singleFactorAuthArgs: SingleFactorAuthArgs
private lateinit var loginParams: LoginParams
private var torusKey: TorusKey? = null

override fun onCreate(savedInstanceState: Bundle?) {

singleFactorAuthArgs = SingleFactorAuthArgs(TorusNetwork.TESTNET)
singleFactorAuth = SingleFactorAuth(singleFactorAuthArgs)

// Setup UI and event handlers
val signInButton = findViewById<Button>(
signInButton.setOnClickListener { signIn() }

private fun signIn() {
val jwt = JWT(idToken) // idToken is the JWT token obtained from auth provider or your custom JWT provider
val sub = jwt.getClaim("sub").asString() // get sub claims
loginParams = LoginParams("web3auth-firebase-examples", "$sub", "$idToken")
try {
torusKey = singleFactorAuth.getKey(loginParams).get()
} catch (e: ExecutionException) {
} catch (e: InterruptedException) {
println("""Private Key: ${torusKey!!.privateKey.toString(16)}""".trimIndent())
println("""Public Address: ${torusKey!!.publicAddress}""".trimIndent())

You can have a look at the this example made on top of this SDK and try it out yourself.