How to use JWT login with auth0 and android-sdk?

hi, I want use JWT to login web3auth get privateKey at android platform. the flow is

  1. android auth0 login via twitter. see this link
  2. after auth succeed, send token to our server, then get JWT id_token
  3. use web3auth sdk to get privateKey. like this

got a error msg: Caused by: [null,null,null,null,null], responses: ["{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32602,\"message\":\"Internal error\",\"data\":\"Error occurred while verifying paramstimesigned is more than 1m0s ago 2023-08-24 11:08:52 +0000 UTC\"},\"id\":322}\n","{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32602,\"message\":\"Internal error\",\"data\":\"Error occurred while verifying paramstimesigned is more than 1m0s ago 2023-08-24 11:08:52 +0000 UTC\"},\"id\":833}\n","{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32602,\"message\":\"Internal error\",\"data\":\"Error occurred while verifying paramstimesigned is more than 1m0s ago 2023-08-24 11:08:52 +0000 UTC\"},\"id\":295}\n","{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32602,\"message\":\"Internal error\",\"data\":\"Error occurred while verifying paramstimesigned is more than 1m0s ago 2023-08-24 11:08:52 +0000 UTC\"},\"id\":131}\n","{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32602,\"message\":\"Internal error\",\"data\":\"Error occurred while verifying paramstimesigned is more than 1m0s ago 2023-08-24 11:08:52 +0000 UTC\"},\"id\":81}\n"]org.torusresearch.torusutils.helpers.PredicateFailedException: could not get enough shares

params like:
network: TorusNetwork.TESTNET
JWT idToken: eyJhbGciOiJSUzI1NiIsImtpZCI6InVuaVBhc3NfMjAyMzA1MTYiLCJ0eXAiOiJKV1QifQ.eyJvcGVuX2lkIjoiYmYwNjcyMmQtMmRlNC00MjQ0LWIwNzItY2M3MTBjOTI0NWJiIiwiaXNzIjoic3BhcmtsZSIsImV4cCI6MTY5Mjg4MjUzMiwibmJmIjoxNjkyODc1MzMyLCJpYXQiOjE2OTI4NzUzMzJ9.almd2Nq9CBvW3_A2Bp-6bV3JxVTe2ejpq00hLaHPh95MAJSvTDkfeTmn-my7zs3Wuik2TeS79L7OLXmTFBW2OdJzDVTSeoybr-nMDUrk9uXDKc9kG2yc4U4cWOA_FiaVlPSwYAZQRCpVnAozljfQCxdozCYtrGI7edi_QjMVaJ1ohBhzh4Fvra7ZV0WEr9kIlf_5i-_0fY3rcP8OLYjPpnb7ITEQPXm4KrhOJbQTzvX6bG42haRsoptq9ckWMyghPIoPR24yHaa9-uy6c9sg5Cpyc0rtTEK98h-hP_J3hXtvyQaZIrinPPAmFVmlweZjoF-TYm7NoKyuasaqia3w4Q
verifier: Sparkle-Custom-Auth-01
verifierId: bf06722d-2de4-4244-b072-cc710c9245bb

code:

    private fun signInJWT(){
        val jwt = JWT(idToken)
        val issuer = jwt.issuer //get registered claims
        Log.d(TAG, "Issuer = $issuer")
        val open_id = jwt.getClaim("open_id").asString() //get sub claims
        Log.d(TAG, "open_id = $open_id")

        loginParams =
            LoginParams("Sparkle-Custom-Auth-01", "$open_id", "$idToken")
        try {
            torusKey = singleFactorAuth.getKey(
                loginParams,
                this.applicationContext,
                86400
            ).get()
        } catch (e: ExecutionException) {
            e.printStackTrace()
        } catch (e: InterruptedException) {
            e.printStackTrace()
        }
        publicAddress = torusKey?.publicAddress.toString()
        Log.e(TAG, "Private Key: ${torusKey?.privateKey?.toString(16)}".trimIndent())
        Log.e(TAG, "Public Address: $publicAddress".trimIndent())
    }

is there any wrong operations? should I use other SDk like plug and play?

@dev16 Welcome Aboard!

Your issue has been forwarded to our team and we will get back with further updates once more information becomes available.

In the meantime, you may refer to this troubleshooting guide for the error you receive:

@dev16 According to the error(“Error occurred while verifying paramstimesigned is more than 1m0s ago 2023-08-24 11:08:52 +0000 UTC”), it seems you are using expired token. Please use fresh token.

yo man, thank you so much! it save my life.

1 Like