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

I want to use JWT login with unity-sdk and auth0.
I want to pass an id_token from auth0 to web3auth vi unity-sdk.
Documents says

To use the `JWT` login, you need to put the jwt token into the `additionalParams` field of the `extraLoginOptions`.

But sample code seems different.
I cannot find what key is available in additionalParams.

Does anyone have samples to use JWT login?

@shuichi.fushimi Thanks for reaching out.

I have forwarded your request to our team to check and will get back with an update once more information becomes available.

In the meantime, are you able to use the sample code for JWT login:

void Start()
{
  web3Auth = GetComponent<Web3Auth>();
  var loginConfigItem = new LoginConfigItem()
  {
    verifier = "custom-jwt-verifier", // get it from web3auth dashboard
    typeOfLogin = TypeOfLogin.JWT,
  };
  web3Auth.setOptions(new Web3AuthOptions()
  {
    redirectUrl = new Uri("torusapp://com.torus.Web3AuthUnity/auth"),
    clientId = "BAwFgL-r7wzQKmtcdiz2uHJKNZdK7gzEf2q-m55xfzSZOw8jLOyIi4AVvvzaEQO5nv2dFLEmf9LBkF8kaq3aErg",
    network = Web3Auth.Network.TESTNET,
    // Optional loginConfig object
    loginConfig = new Dictionary<string, LoginConfigItem>
    {
      {"jwt", loginConfigItem}
    }
  });
}
public void login()
{
  var selectedProvider = Provider.JWT;
  var options = new LoginParams()
  {
    loginProvider = selectedProvider,
    extraLoginOptions = new ExtraLoginOptions()
    {
      verifierIdField = "sub",
      id_token = "your_jwt_token",
    }
  };
  web3Auth.login(options);
}

Here is an example for Unity with Auth0:

@vjgee
Thank you for your rapid response :smiley:

Yes, I have already tried the example and it does not work well because ExtraLoginOptions does not have id_token field. (please see following definition of ExtraLoginOptions)
I also passed my_jwt_token to id_token_hint but it does not work too.

The example code and the following sentence in your documents seems doing different thing.

To use the JWT login, you need to put the jwt token into the additionalParams field of the extraLoginOptions.

Our team are checking on this and we will get back with further updates once more information becomes available.

1 Like

@vjgee
Hello, how is it?

@shuichi.fushimi This has been fixed in the latest version 1.3 of the Unity SDK. Please upgrade to the same

1 Like

@vjgee

Thank you for updating.
I tried JWT token with updated sdk and found another problem.

When I login with setting auth0 idToken to here, OpenLogin page became like following picture.

And console log shows following errors.

Do you have any idea how to solve this?

customauth.esm.js:1994 Error: Duplicate token found
    at torusUtils.esm.js:78:20
    at <anonymous>
getRedirectResult @ customauth.esm.js:1994
loglevelSentry.esm.js:56 Error: Could not get result from torus nodes 
 Duplicate token found
    at _ (customAuthError.ts:67:11)
    at Proxy.created (Callback.vue:148:53) Object Object 'Could not get result from torus nodes \n Duplicate token found' Object 'mounted caught'
n @ loglevelSentry.esm.js:56
1 Like

I am checking this with our team and we will get back with further updates.

1 Like

Sorry for the delay, @shuichi.fushimi. This is a known error which is discussed in brief here. Basically, this error is thrown when the JWT is sent twice in the same request.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.