# \[Archive\] Cannot login with custom jwt

**URL:** <https://builder.metamask.io/t/archive-cannot-login-with-custom-jwt/1999>\
**Category:** Embedded Wallets (Web3Auth)\
**Created:** [April 10, 2023, 9:58am UTC](https://builder.metamask.io/t/archive-cannot-login-with-custom-jwt/1999 "2023-04-10T09:58:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![denisa.halmaghi](https://avatars.discourse-cdn.com/v4/letter/d/d07c76/32.png) [@denisa.halmaghi](https://builder.metamask.io/u/denisa.halmaghi)\
**Post date:** [April 10, 2023, 9:58am UTC](https://builder.metamask.io/t/archive-cannot-login-with-custom-jwt/1999/1 "2023-04-10T09:58:38Z")

</div>

> **🏛 Archived Content from Web3Auth Community**
> 
> This topic was originally posted by **denisa.halmaghi** on 4/10/2023.  
> This content has been migrated from our previous community forum to preserve valuable discussions.

* * *

Hello! I’m having trouble with the custom JWT authentication. I’m currently trying to integrate web3auth with keycloak. I followed the points in the documentation but it does not seem to work.

- SDK Version:  
“@web3auth/base”: “^5.1.0”,  
“@web3auth/metamask-adapter”: “^5.1.0”,  
“@web3auth/no-modal”: “^5.1.0”,  
“@web3auth/openlogin-adapter”: “^5.1.1”

- Platform:  
macOS 13.2.1  
Node 18.12.1  
Vue ^3.2.38

- Browser Console Screenshots:  

It appears that when it tries to get the jwt verifier from loginConfig it does not find anything and I think this might be because loginConfig is not present in the request, but I don’t know why and am currently stuck here.

In case it helps, this is the request object:

```auto
 const r = req as ValidatedJRPCRequest<Record<string, unknown>[]>;

```

Additionally, Typescript is yelling at me and telling me that loginConfig is not present in OpenloginAdapterOptions (maybe this helps somehow).

- Related to Custom Authentication? Please provide the following info too: **(Optional)**
  - Verifier Name: web3-auth-verifier-test
  - JWKS Endpoint: “[https://lemur-4.cloud-iam.com/auth/realms/web3auth-keycloak-test-deployment/protocol/openid-connect/certs](https://lemur-4.cloud-iam.com/auth/realms/web3auth-keycloak-test-deployment/protocol/openid-connect/certs)”
  - Sample idToken(JWT)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hVuJGclpysxENNsF2xnnktAev1dOtYIuyeKR9eccE1YI9D5uAFzZFCxjcmEhFb7nFjfGTJi-5Y1N4_yFVL4BJVhmy1J5AHqZT-BKn2AGtVGM75gm4Z9NKbENMl4xkVlzF6GTtNY3YykQE9wMA8d7AYZlBW0aVGTAK5NllEXJlctNNmyg02R_rjqBPQ0roNmVklOt5gptpkowYOHE-wm_JshCT231gmB7iEBXqKqKilzoAtOKuHbouRdXOA7glYYJhs3InGeghiOaosl-8yF-9F1GIzsv_3n4m9h4_htOhEA`

**Please provide the Web3Auth initialization and login code snippet below:**  
initialization:

```auto
  async function init() {
    const auth = new Web3AuthNoModal(web3AuthConfig);
const openloginAdapter = new OpenloginAdapter({
  adapterSettings: {
    uxMode: 'redirect',
  },
  loginSettings: {
    mfaLevel: 'none',
    redirectUrl: 'http://localhost:5173/auth/login',
  },

  loginConfig: {
    jwt: {
      verifier: 'web3-auth-verifier-test',
      typeOfLogin: 'jwt',
      clientId: 'client1',
      domain:
        'https://lemur-4.cloud-iam.com/auth/realms/web3auth-keycloak-test-deployment/protocol/openid-connect/auth',
    },
  },
});

const metamaskAdapter = new MetamaskAdapter({});

auth.configureAdapter(metamaskAdapter);
auth.configureAdapter(openloginAdapter);

StaticWrapper.web3Auth = auth;

await auth.init();

if (auth.provider) {
  provider.value = auth.provider;
}

```

login:

```auto
    provider.value = await StaticWrapper.web3Auth.connectTo(
      WALLET_ADAPTERS.OPENLOGIN,
      {
        loginProvider: 'jwt',
        extraLoginOptions: {
          id_token: 'idToken', // in JWT Format
          verifierIdField: 'sub', // same as your JWT Verifier ID
          response_type: 'token', //! check if correct
          redirectUrl: 'http://localhost:5173/auth/login',
        },
      }
    );

```

---

<div class="post-metadata">

**Author:** ![shahbaz](https://yyz1.discourse-cdn.com/flex011/user_avatar/builder.metamask.io/shahbaz/32/1527_2.png) [@shahbaz](https://builder.metamask.io/u/shahbaz)\
**Post date:** [April 10, 2023, 10:31am UTC](https://builder.metamask.io/t/archive-cannot-login-with-custom-jwt/1999/2 "2023-04-10T10:31:35Z")

</div>

Hey @denisa.halmaghi

Please remove the clientId and domain from here.

> [@denisa.halmaghi](#):
>
> ```auto
> loginConfig: {
> jwt: {
> verifier: 'web3-auth-verifier-test',
> typeOfLogin: 'jwt',
> clientId: 'client1',
> domain:
> 'https://lemur-4.cloud-iam.com/auth/realms/web3auth-keycloak-test-deployment/protocol/openid-connect/auth',
> },
> },
> 
> ```

And remove `response_type` and `redirectUrl` from here. Also, I assume the `idToken` passed here is the unused recently generated one.

> [@denisa.halmaghi](#):
>
> ```auto
> extraLoginOptions: {
> id_token: 'idToken', // in JWT Format
> verifierIdField: 'sub', // same as your JWT Verifier ID
> response_type: 'token', //! check if correct
> redirectUrl: 'http://localhost:5173/auth/login',
> },
> 
> ```

Please try again after changing the suggested edits.

---

<div class="post-metadata">

**Author:** ![denisa.halmaghi](https://avatars.discourse-cdn.com/v4/letter/d/d07c76/32.png) [@denisa.halmaghi](https://builder.metamask.io/u/denisa.halmaghi)\
**Post date:** [April 10, 2023, 11:09am UTC](https://builder.metamask.io/t/archive-cannot-login-with-custom-jwt/1999/3 "2023-04-10T11:09:05Z")

</div>

I made the changes, I get the same error:

```auto
loglevelSentry.esm.js:56 Error: unknown
    at s.translateError (loglevelSentry.esm.js:16:59)
    at l.error (loglevelSentry.esm.js:54:53)
    at openloginJrpc.esm.js:237:13
    at openloginJrpc.esm.js:463:9
    at new Promise (<anonymous>)
    at T._runReturnHandlers (openloginJrpc.esm.js:462:13)
    at async T._processRequest (openloginJrpc.esm.js:627:46)
    at async T._handle (openloginJrpc.esm.js:602:5) 'OpenLogin - RPC Error: Invalid loginProvider or custom loginProvider data not available' {code: -32602, message: 'Invalid loginProvider or custom loginProvider data not available', data: undefined}

```

---

<div class="post-metadata">

**Author:** ![denisa.halmaghi](https://avatars.discourse-cdn.com/v4/letter/d/d07c76/32.png) [@denisa.halmaghi](https://builder.metamask.io/u/denisa.halmaghi)\
**Post date:** [April 10, 2023, 11:10am UTC](https://builder.metamask.io/t/archive-cannot-login-with-custom-jwt/1999/4 "2023-04-10T11:10:43Z")

</div>

Also, I thought it should also work if i do not provide the token? I was expecting the openlogin window to redirect me to the specified domain (like it happens with google, facebook etc.) and that the login flow should proceed from there

---

<div class="post-metadata">

**Author:** ![shahbaz](https://yyz1.discourse-cdn.com/flex011/user_avatar/builder.metamask.io/shahbaz/32/1527_2.png) [@shahbaz](https://builder.metamask.io/u/shahbaz)\
**Post date:** [April 10, 2023, 12:05pm UTC](https://builder.metamask.io/t/archive-cannot-login-with-custom-jwt/1999/5 "2023-04-10T12:05:10Z")

</div>

Hey @denisa.halmaghi

Did you create this verifier? On which web3auth network?

 ![](https://web3auth.io/community/letter_avatar_proxy/v4/letter/d/d07c76/48.png) denisa.halmaghi:

> ```auto
> loginConfig: {
> jwt: {
> verifier: 'web3-auth-verifier-test', // <-- Did you create this verifier?
> typeOfLogin: 'jwt',
> 
> ```

Also, please refer to this code while initializing for a custom login provider.

```
  <a href="https://github.com/Web3Auth/web3auth-pnp-examples/blob/main/web-no-modal-sdk/custom-authentication/single-verifier-examples/firebase-no-modal-example/src/App.tsx#L42-L66" target="_blank" rel="noopener">github.com</a>

```

#### [Web3Auth/web3auth-pnp-examples/blob/main/web-no-modal-sdk/custom-authentication/single-verifier-examples/firebase-no-modal-example/src/App.tsx#L42-L66](https://github.com/Web3Auth/web3auth-pnp-examples/blob/main/web-no-modal-sdk/custom-authentication/single-verifier-examples/firebase-no-modal-example/src/App.tsx#L42-L66)

```
<pre class="onebox"><code class="lang-tsx">
  <ol class="start lines" start="42" style="counter-reset: li-counter 41 ;">
      <li>const init = async () =&gt; {</li>
      <li> try {</li>
      <li> const chainConfig = {</li>
      <li> chainNamespace: CHAIN_NAMESPACES.EIP155,</li>
      <li> chainId: "0x5", // Please use 0x1 for Mainnet</li>
      <li> rpcTarget: "https://rpc.ankr.com/eth_goerli",</li>
      <li> displayName: "Goerli Testnet",</li>
      <li> blockExplorer: "https://goerli.etherscan.io/",</li>
      <li> ticker: "ETH",</li>
      <li> tickerName: "Ethereum",</li>
      <li> };</li>
      <li> const web3auth = new Web3AuthNoModal({</li>
      <li> clientId,</li>
      <li> chainConfig,</li>
      <li> web3AuthNetwork: "cyan",</li>
      <li> useCoreKitKey: false,</li>
      <li> });</li>
      <li></li>
      <li> const privateKeyProvider = new EthereumPrivateKeyProvider({ config: { chainConfig } });</li>
      <li></li>
  </ol>
</code></pre>

```

This file has been truncated. [show original](https://github.com/Web3Auth/web3auth-pnp-examples/blob/main/web-no-modal-sdk/custom-authentication/single-verifier-examples/firebase-no-modal-example/src/App.tsx#L42-L66)

> [@denisa.halmaghi](#):
>
> I thought it should also work if i do not provide the token? I was expecting the openlogin window to redirect me to the specified domain (like it happens with google, facebook etc.) and that the login flow should proceed from there

For custom login providers, id\_token is needed. For other login providers like `google`, `facebook`, `twitch`, `discord` and `auth0` you don’t need to, but in that case, one has to provide clientId and domains, respectively.

---

<div class="post-metadata">

**Author:** ![denisa.halmaghi](https://avatars.discourse-cdn.com/v4/letter/d/d07c76/32.png) [@denisa.halmaghi](https://builder.metamask.io/u/denisa.halmaghi)\
**Post date:** [April 10, 2023, 12:42pm UTC](https://builder.metamask.io/t/archive-cannot-login-with-custom-jwt/1999/6 "2023-04-10T12:42:42Z")

</div>

Yes, i created the verifier and it is also active:

[![Screenshot 2023-04-10 at 15.26.08](https://canada1.discourse-cdn.com/flex011/uploads/metamaskbuilderhub/original/2X/1/1411409be50ea601ad6508906d66df8167f2550d.png)
Screenshot 2023-04-10 at 15.26.08720×406 22.5 KB
](https://community.web3auth.io/community/community/uploads/default/original/1X/588c31fe6b9167c11bfe584376bf4434fa6a8811.png "Screenshot 2023-04-10 at 15.26.08")

---

<div class="post-metadata">

**Author:** ![denisa.halmaghi](https://avatars.discourse-cdn.com/v4/letter/d/d07c76/32.png) [@denisa.halmaghi](https://builder.metamask.io/u/denisa.halmaghi)\
**Post date:** [April 10, 2023, 3:03pm UTC](https://builder.metamask.io/t/archive-cannot-login-with-custom-jwt/1999/7 "2023-04-10T15:03:26Z")

</div>

I adapted the code according to the github example you provided and it worked. Thank you!
