Skip to content

Commit

Permalink
fix: app
Browse files Browse the repository at this point in the history
  • Loading branch information
metalurgical committed Sep 2, 2024
1 parent 8691c6c commit b7699fd
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions app/src/main/java/com/web3auth/sfaexample/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package com.web3auth.sfaexample

import android.app.Application
import android.os.Build
import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
import androidx.test.core.app.ApplicationProvider
import com.web3auth.singlefactorauth.SingleFactorAuth
import com.web3auth.singlefactorauth.types.LoginParams
import com.web3auth.singlefactorauth.types.SingleFactorAuthArgs
Expand All @@ -33,12 +29,21 @@ class MainActivity : AppCompatActivity() {
btnTorusKey.setOnClickListener {
getTorusKey()
}

val idToken = JwtUtils.generateIdToken(TORUS_TEST_EMAIL)
sfaParams =
SingleFactorAuthArgs(Web3AuthNetwork.SAPPHIRE_MAINNET, "YOUR_CLIENT_ID", null,0)
singleFactorAuth = SingleFactorAuth(sfaParams, this)
singleFactorAuth.initialize(this.applicationContext)
singleFactorAuth.getKey(loginParams, this.applicationContext)
loginParams = LoginParams(TEST_VERIFIER, TORUS_TEST_EMAIL, idToken)

// Consider exposing getSessionId() to avoid this try..catch in all implementations of this SDK
try {
// Already has done login and has sessionId stored.
singleFactorAuth.initialize(this.applicationContext)
} catch (ex: java.lang.Exception) {
// Try login and create new session which will then be stored
singleFactorAuth.getKey(loginParams, this)
singleFactorAuth.initialize(this.applicationContext)
}
}

private fun getTorusKey() {
Expand Down

0 comments on commit b7699fd

Please sign in to comment.