# \[Archive\] Facing Error: Duplicate token found with @web3auth/single-factor-auth sdk

**URL:** https://builder.metamask.io/t/archive-facing-error-duplicate-token-found-with-web3auth-single-factor-auth-sdk/1153
**Category:** Embedded Wallets (Web3Auth)
**Created:** [November 13, 2024, 6:19am UTC](https://builder.metamask.io/t/archive-facing-error-duplicate-token-found-with-web3auth-single-factor-auth-sdk/1153 "2024-11-13T06:19:13Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![abhishek.sagu](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@abhishek.sagu](https://builder.metamask.io/u/abhishek.sagu)
#### Post date: [November 13, 2024, 6:19am UTC](https://builder.metamask.io/t/archive-facing-error-duplicate-token-found-with-web3auth-single-factor-auth-sdk/1153/1 "2024-11-13T06:19:13Z")

</div>

> **🏛 Archived Content from Web3Auth Community**
> 
> This topic was originally posted by **abhishek.sagu** on 11/13/2024.  
> This content has been migrated from our previous community forum to preserve valuable discussions.

* * *

When asking for help in this category, please make sure to provide the following details:

- SDK Version:^8.1.1
- Platform: Web
- Browser Console Screenshots:
- If the issue is related to Custom Authentication, please include the following information (optional):
  - Verifier Name: staging-axr-wallet
  - JWKS Endpoint: [https://api-staging.axirwallet.com/.well-known/jwks.json](https://api-staging.axirwallet.com/.well-known/jwks.json)
  - Sample idToken (JWT): eyJ0eXAiOiJqd3QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjhWclhWcVRRbG1uX084X3g5Y2d4NVY0RElsNmR3TXlqYVA1REN4Q2JOcnMifQ.eyJzdWIiOiI2NTYiLCJuYW1lIjoiYWJoaXNoZWtzYWd1KzEwNiIsImVtYWlsIjoiYWJoaXNoZWtzYWd1KzEwNkBnbWFpbC5jb20iLCJwaG9uZU51bWJlciI6Iis5MTk5NzE1MTI5MzkiLCJleHAiOjE3MzE1NjQ1NTMsImlhdCI6MTczMTQ3ODE1MywiaXNzIjoiaHR0cHM6Ly9hcGktc3RhZ2luZy5heGlyd2FsbGV0LmNvbSIsImF1ZCI6ImF4ci13YWxsZXQifQ.i4dOhTuJGe4DXC\_6YX09oZ7XB6yj2PXLqqrpQLKpIKWWWoeSnE6Zv6384SvdG-OzoAgy\_GHz1yQ4Xs4Wsm75ZKYGGzmqrwVRuK-J8WkuzVyOEzJ4VipVSfNW5XHSSxGNBKu-qE4Vgv0zS2EQBxcP0-XAVlMEdCr-VFNvP\_v\_XuYWrhX82C7o3rLHuCXEayyx6f2azT8P\_g7E4efxqcg3k3Y59poyOZVod0hSrO0FDFeoANLmMXWUmKqPANOTMbIBVKtAEysVeWA\_-QwFGjg7GbUSF4lPDg\_tV50xKHmICACk4mVpqPNk12774t8m5yuBXwvRp56-yzrUNh5wLzG17g

web3Auth is initialized like this

const chainConfig = {  
chainId: “0x1”,  
displayName: “Ethereum Mainnet”,  
chainNamespace: CHAIN\_NAMESPACES.EIP155,  
tickerName: “Ethereum”,  
ticker: “ETH”,  
decimals: 18,  
rpcTarget: “[https://rpc.ankr.com/eth](https://rpc.ankr.com/eth)”,  
blockExplorerUrl: “[https://etherscan.io](https://etherscan.io)”,  
};

```
    const privateKeyProvider = new EthereumPrivateKeyProvider({
      config: { chainConfig },
    });
const web3authSfa = new Web3Auth({
  clientId,
  web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_DEVNET,
  usePnPKey: false,
  privateKeyProvider,
});

await web3authSfa.init();

```

web3AuthSfa is used like this

try {  
if (!web3authSfa) {  
console.log(“Web3Auth Single Factor Auth SDK not initialized yet”);  
return;  
}

```
    const isConnected = await web3authSfa.status;
    let telegramGeneratedPrivateKey;
if (isConnected.toLowerCase() === 'connected') {
  telegramGeneratedPrivateKey = await web3authSfa.torusPrivKey;
} else {

 

  await web3authSfa.connect({
    loginMethod:'jwt',
    verifier,
    verifierId: verifierId,
    idToken: authToken,
  });

  console.log("**@ web3AuthSfa connected ");

  telegramGeneratedPrivateKey = await web3authSfa.torusPrivKey;

}

```

NOTE:- I have checked that i am passing different JWT each time but still facing this error , i checked that the jwt itself has changed and the decoded iat and exp timestamp also changed , so how can i fix this issue.

---

<div class="post-metadata">

### Author: ![w3abot](https://avatars.discourse-cdn.com/v4/letter/w/4da419/32.png) [@w3abot](https://builder.metamask.io/u/w3abot)
#### Post date: [November 13, 2024, 6:20am UTC](https://builder.metamask.io/t/archive-facing-error-duplicate-token-found-with-web3auth-single-factor-auth-sdk/1153/2 "2024-11-13T06:20:26Z")

</div>

Hi Abhishek! Thanks for reaching out with your issue. I understand you’re encountering a “Duplicate token found” error while using the `@web3auth/single-factor-auth` SDK.

Here’s a summary of the information you’ve provided, which will help our support team to assist you more effectively:

### Issue Summary:

- **SDK Details:** `@web3auth/single-factor-auth`
- **SDK Version:** `^8.1.1`
- **Platform:** Web
- **Error Encountered:** Duplicate token found
- **Verifier Name:** `staging-axr-wallet`
- **JWKS Endpoint:** [Link](https://api-staging.axirwallet.com/.well-known/jwks.json)
- **Sample idToken (JWT):** Provided

### Initialization Code Snippet:

```javascript
const chainConfig = {
    chainId: "0x1",
    displayName: "Ethereum Mainnet",
    chainNamespace: CHAIN_NAMESPACES.EIP155,
    tickerName: "Ethereum",
    ticker: "ETH",
    decimals: 18,
    rpcTarget: "https://rpc.ankr.com/eth",
    blockExplorerUrl: "https://etherscan.io",
};
const privateKeyProvider = new EthereumPrivateKeyProvider({
config: { chainConfig },
});
const web3authSfa = new Web3Auth({
clientId,
web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_DEVNET,
usePnPKey: false,
privateKeyProvider,
});

```

### Usage Code Snippet:

```javascript
try {
    if (!web3authSfa) {
      console.log("Web3Auth Single Factor Auth SDK not initialized yet");
      return;
    }
const isConnected = await web3authSfa.status;
let telegramGeneratedPrivateKey;

if (isConnected.toLowerCase() === 'connected') {
  telegramGeneratedPrivateKey = await web3authSfa.torusPrivKey;
} else {
  await web3authSfa.connect({
    loginMethod:'jwt',
    verifier,
    verifierId: verifierId,
    idToken: authToken,
  });
  console.log("**@ web3AuthSfa connected ");
  telegramGeneratedPrivateKey = await web3authSfa.torusPrivKey;
}

```

### Notes:

- You mentioned checking that you’re passing different JWTs each time, but you’re still receiving the error. It may be worth confirming if the `verifierId` is unique for each request as well, as reusing that might lead to issues.

For the next steps, I recommend checking your console for any additional error messages or logs that might help further diagnose the issue. If possible, please provide screenshots of the browser console during the error occurrence, as this could provide more context.

We’ll ensure that your request is sent to our support team for further investigation. If you have any other questions or need further assistance, feel free to ask!

> Note: This response was generated by an AI bot and may require further verification. The Web3Auth support team has tracked this issue and will be responding as soon as possible.

---

<div class="post-metadata">

### Author: ![abhishek.sagu](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@abhishek.sagu](https://builder.metamask.io/u/abhishek.sagu)
#### Post date: [November 14, 2024, 6:10am UTC](https://builder.metamask.io/t/archive-facing-error-duplicate-token-found-with-web3auth-single-factor-auth-sdk/1153/3 "2024-11-14T06:10:39Z")

</div>

hi @shahbaz , could you please help me with this ? Thanks

---

<div class="post-metadata">

### Author: ![abhishek.sagu](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@abhishek.sagu](https://builder.metamask.io/u/abhishek.sagu)
#### Post date: [November 14, 2024, 12:00pm UTC](https://builder.metamask.io/t/archive-facing-error-duplicate-token-found-with-web3auth-single-factor-auth-sdk/1153/4 "2024-11-14T12:00:44Z")

</div>

hi @shahbaz , could you please help me with this? How do i fix this issue ?

---

<div class="post-metadata">

### Author: ![abhishek.sagu](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@abhishek.sagu](https://builder.metamask.io/u/abhishek.sagu)
#### Post date: [November 15, 2024, 5:17am UTC](https://builder.metamask.io/t/archive-facing-error-duplicate-token-found-with-web3auth-single-factor-auth-sdk/1153/5 "2024-11-15T05:17:37Z")

</div>

hi @shahbaz , any updates here ?

---

<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: [November 15, 2024, 5:24am UTC](https://builder.metamask.io/t/archive-facing-error-duplicate-token-found-with-web3auth-single-factor-auth-sdk/1153/6 "2024-11-15T05:24:59Z")

</div>

Hey @abhishek.sagu

Are you calling the login function twice?

 ![](https://canada1.discourse-cdn.com/flex011/uploads/metamaskbuilderhub/original/1X/4bea15d5fdfd372b2e7fae21263c61fab3da9379.png)

```
  <a href="https://web3auth.io/docs/troubleshooting/jwt-errors#duplicate-token" target="_blank" rel="noopener">web3auth.io</a>

```

### [JWT Errors | Documentation | Web3Auth](https://web3auth.io/docs/troubleshooting/jwt-errors#duplicate-token)

JWT Errors | Documentation - Web3Auth

---

<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: [November 15, 2024, 5:31am UTC](https://builder.metamask.io/t/archive-facing-error-duplicate-token-found-with-web3auth-single-factor-auth-sdk/1153/7 "2024-11-15T05:31:57Z")

</div>

> [@abhishek.sagu](#):
>
> `loginMethod:'jwt',`

We don’t have loginMethod in SFA. Please take a reference from here: [Usage of Single Factor Auth JS SDK | Documentation | Web3Auth](https://web3auth.io/docs/sdk/sfa/sfa-js/usage#loginparams)

We even have a telegram example, from where you can take reference:

 ![](https://github.githubassets.com/favicons/favicon.svg)

```
  <a href="https://github.com/Web3Auth/web3auth-pnp-examples/tree/main/web-no-modal-sdk/custom-authentication/single-verifier-examples/telegram-no-modal-example" target="_blank" rel="noopener">github.com</a>

```

### [web3auth-pnp-examples/web-no-modal-sdk/custom-authentication/single-verifier-exa...](https://github.com/Web3Auth/web3auth-pnp-examples/tree/main/web-no-modal-sdk/custom-authentication/single-verifier-examples/telegram-no-modal-example)

Contribute to Web3Auth/web3auth-pnp-examples development by creating an account on GitHub.

---

<div class="post-metadata">

### Author: ![abhishek.sagu](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@abhishek.sagu](https://builder.metamask.io/u/abhishek.sagu)
#### Post date: [November 18, 2024, 5:55am UTC](https://builder.metamask.io/t/archive-facing-error-duplicate-token-found-with-web3auth-single-factor-auth-sdk/1153/8 "2024-11-18T05:55:12Z")

</div>

No @shahbaz i am not calling the login function twice. I just call the login function once and it gives me the duplicate token error

---

<div class="post-metadata">

### Author: ![abhishek.sagu](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@abhishek.sagu](https://builder.metamask.io/u/abhishek.sagu)
#### Post date: [November 18, 2024, 6:07am UTC](https://builder.metamask.io/t/archive-facing-error-duplicate-token-found-with-web3auth-single-factor-auth-sdk/1153/9 "2024-11-18T06:07:37Z")

</div>

I want to create a private key with only 1 required share , will this no modal sdk work ? I am currently trying to use @web3auth/single-factor-auth with which i am facing this duplicate token error .

---

<div class="post-metadata">

### Author: ![abhishek.sagu](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@abhishek.sagu](https://builder.metamask.io/u/abhishek.sagu)
#### Post date: [November 18, 2024, 12:02pm UTC](https://builder.metamask.io/t/archive-facing-error-duplicate-token-found-with-web3auth-single-factor-auth-sdk/1153/10 "2024-11-18T12:02:28Z")

</div>

hi @shahbaz , how can i fix this issue. I am only calling the method once and that too with the new token.

---

<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: [November 19, 2024, 5:40am UTC](https://builder.metamask.io/t/archive-facing-error-duplicate-token-found-with-web3auth-single-factor-auth-sdk/1153/11 "2024-11-19T05:40:00Z")

</div>

Okay, and how are you generating the token?

---

<div class="post-metadata">

### Author: ![abhishek.sagu](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@abhishek.sagu](https://builder.metamask.io/u/abhishek.sagu)
#### Post date: [November 19, 2024, 5:53am UTC](https://builder.metamask.io/t/archive-facing-error-duplicate-token-found-with-web3auth-single-factor-auth-sdk/1153/12 "2024-11-19T05:53:14Z")

</div>

hi @shahbaz , here is how i am generating the token

async getIdToken(newUser, showOnlyVerified = false) {  
const ks = fs.readFileSync(‘keys\_rsa.json’);

```
const keyStore = await jose.JWK.asKeyStore(ks.toString());
const [key] = keyStore.all({ use: 'sig' });
const opt = {
compact: true,
jwk: key,
fields: { typ: ‘jwt’ }
};
const tokenPayload = {
sub: ${newUser.id}, // must be unique to each user
name: newUser.username,
email: showOnlyVerified ? newUser.getEmailVerified() : newUser.email,
phoneNumber: showOnlyVerified ? newUser.getPhoneVerified() : newUser.phone_number,
exp: Math.floor(Date.now() / 1000) + 86400, // expires in 1 day
iat: Math.floor(Date.now() / 1000),
iss: process.env.WEB3AUTH_ISS,
aud: ‘axr-wallet’,
};
const payload = JSON.stringify(tokenPayload);

```

}

---

<div class="post-metadata">

### Author: ![abhishek.sagu](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@abhishek.sagu](https://builder.metamask.io/u/abhishek.sagu)
#### Post date: [November 19, 2024, 7:28am UTC](https://builder.metamask.io/t/archive-facing-error-duplicate-token-found-with-web3auth-single-factor-auth-sdk/1153/13 "2024-11-19T07:28:07Z")

</div>

hi @shahbaz , @Ayush , i tried by increasing the exp timestamp too but its still giving me the same duplicate token error. How can i fix this ?

---

<div class="post-metadata">

### Author: ![abhishek.sagu](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@abhishek.sagu](https://builder.metamask.io/u/abhishek.sagu)
#### Post date: [November 20, 2024, 8:36am UTC](https://builder.metamask.io/t/archive-facing-error-duplicate-token-found-with-web3auth-single-factor-auth-sdk/1153/14 "2024-11-20T08:36:01Z")

</div>

hi @shahbaz , any updates here ? Is there any way to fix it ?

---

<div class="post-metadata">

### Author: ![Ayush](https://yyz1.discourse-cdn.com/flex011/user_avatar/builder.metamask.io/ayush/32/1540_2.png) [@Ayush](https://builder.metamask.io/u/Ayush)
#### Post date: [November 21, 2024, 2:37am UTC](https://builder.metamask.io/t/archive-facing-error-duplicate-token-found-with-web3auth-single-factor-auth-sdk/1153/15 "2024-11-21T02:37:02Z")

</div>

Hey @abhishek.sagu, we’ll have a look today. I’ll update you asap

---

<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: [November 22, 2024, 8:02am UTC](https://builder.metamask.io/t/archive-facing-error-duplicate-token-found-with-web3auth-single-factor-auth-sdk/1153/16 "2024-11-22T08:02:57Z")

</div>

Hey @abhishek.sagu

And how are you allowing the users to authenticate?
