# \[Archive\] How get public key from a wallet using custom auth verifier

**URL:** <https://builder.metamask.io/t/archive-how-get-public-key-from-a-wallet-using-custom-auth-verifier/1628>\
**Category:** Embedded Wallets (Web3Auth)\
**Created:** [January 30, 2024, 2:54pm UTC](https://builder.metamask.io/t/archive-how-get-public-key-from-a-wallet-using-custom-auth-verifier/1628 "2024-01-30T14:54:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rsaquicela](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@rsaquicela](https://builder.metamask.io/u/rsaquicela)\
**Post date:** [January 30, 2024, 2:54pm UTC](https://builder.metamask.io/t/archive-how-get-public-key-from-a-wallet-using-custom-auth-verifier/1628/1 "2024-01-30T14:54:20Z")

</div>

> **🏛 Archived Content from Web3Auth Community**
> 
> This topic was originally posted by **rsaquicela** on 1/30/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: ^3.1.0
- Platform: NodeJS
- Browser Console Screenshots:
- If the issue is related to Custom Authentication, please include the following information (optional):
  - Verifier Name: w3a-key
  - JWKS Endpoint: [https://staging-ws.origos.io/.well-known/jwks.json](https://staging-ws.origos.io/.well-known/jwks.json)
  - Sample idToken (JWT):  
eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImNiZmU0YTc4LTkxNzEtNDMwMy04ODRkLWFmMmQ1MDI0YmZlNyJ9.eyJ1c2VySWQiOiJmMzhiNTg5ZS05Y2I5LTRjYWMtODA5Yy05MmI1NGVhMjRkNzEiLCJhdWQiOiJCTHFyQUI1MmU2RmUySE1SWC12NVVqVjZxWFR3bHgxVHBvVDFMQW01Mk1kX08wU1RfNVA3QmxYZjdBVmZmVlNvNUJYRTZ6UjVLSlVSU1FpZ3Z3UGRtWGsiLCJpc3MiOiJodHRwczovL2FwaS1hdXRoLndlYjNhdXRoLmlvIiwibmFtZSI6ImFwaS13ZWIzYXV0aCIsImlhdCI6MTcwNjU2ODgxNSwiZXhwIjoxNzA2NTcyNDE1LCJ3YWxsZXRzIjpbeyJ0eXBlIjoidzNhLWtleSIsImFkZHJlc3MiOiIweGI2YTdkYWZlMDA2YzM4OTU4Y2Y1NmZjNmQ4MzU2YWFiMTFmYjY1ZjAifV19.rPOSaxIhOn\_yJ0BlupRY1WWi834EM4GtLS\_r6tVO7-RCYgoGzMLDV6ZisCl22KixgfdPYKJJnAo7J1WOnmYSHNM6m7-ZfFTfqCQ4joDW6m8n6tuG5WSxzmMei54Jp7px8l-L0JMmd7aczDHHCxHEYeKCBHTpeV4s1aV3p7pCXVGF\_tnuIT\_JH2xaZcguzgLajytoZd-DfFmF2aS6EX6AT24F9yHtaay6X6G6grkyJjYfbfmEoWhZwZkcm6Yf8kvB09JIYnTDmyhPDz\_mL2KjfNQilGhE4608LlFMv6S8t9t717yRDZ3GrgOU\_C0gs4tG4jZpOc4jHLBPgnrs3c99ew

Also, kindly provide the Web3Auth initialization and login code snippet below. This will help us better understand your issue and provide you with the necessary assistance.

const { Web3Auth } = require(“@web3auth/node-sdk”);  
const { EthereumPrivateKeyProvider } = require(“@web3auth/ethereum-provider”);  
const jwt = require(‘jsonwebtoken’);  
const fs = require(‘fs’);

const clientId = “BPi5PB\_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe\_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ”; // Get your Client ID from Web3Auth Dashboard

const verifier = “w3a-node-demo”;

const web3auth = new Web3Auth({  
clientId,  
web3AuthNetwork: “sapphire\_mainnet”, // Get your Network ID from Web3Auth Dashboard  
});

const ethereumProvider = new EthereumPrivateKeyProvider({  
config: {  
chainConfig: {  
chainId: “0x1”,  
rpcTarget: “[https://rpc.ankr.com/eth](https://rpc.ankr.com/eth)”  
}  
}  
});

web3auth.init({ provider: ethereumProvider });

var privateKey = fs.readFileSync(‘privateKey.pem’);

var sub = Math.random().toString(36).substring(7);

var token = jwt.sign(  
{  
sub: sub,  
name: ‘Agrawal Alam Mishra Rawski Bherwani’,  
email: ‘devrel@web3auth.io’,  
aud: ‘urn:api-web3auth-io’,  
iss: ‘[https://web3auth.io](https://web3auth.io)’,  
iat: Math.floor(Date.now() / 1000),  
exp: Math.floor(Date.now() / 1000) + 60 \* 60,  
},  
privateKey,  
{ algorithm: ‘RS256’, keyid: ‘2ma4enu1kdvw5bo9xsfpi3gcjzrt6q78yl0h’ },  
);

const connect = async () =\> {  
const provider = await web3auth.connect({  
verifier: “w3a-node-demo”, // replace with your verifier name  
verifierId: sub, // replace with your verifier id’s value, for example, sub value of JWT Token, or email address.  
idToken: token, // replace with your newly created unused JWT Token.  
});  
const eth\_private\_key = await provider.request({ method: “eth\_private\_key” });  
console.log("ETH PrivateKey: ", eth\_private\_key);  
const eth\_address = await provider.request({ method: “eth\_accounts” });  
console.log("ETH Address: ", eth\_address[0]);  
process.exit(0);  
};  
connect();

I need get wallet **eth\_public\_key**

---

<div class="post-metadata">

**Author:** ![vjgee](https://avatars.discourse-cdn.com/v4/letter/v/b5e925/32.png) [@vjgee](https://builder.metamask.io/u/vjgee)\
**Post date:** [January 31, 2024, 5:14am UTC](https://builder.metamask.io/t/archive-how-get-public-key-from-a-wallet-using-custom-auth-verifier/1628/2 "2024-01-31T05:14:02Z")

</div>

@rsaquicela Welcome Aboard!

Your request is under review and we will get back with further updates.

---

<div class="post-metadata">

**Author:** ![vjgee](https://avatars.discourse-cdn.com/v4/letter/v/b5e925/32.png) [@vjgee](https://builder.metamask.io/u/vjgee)\
**Post date:** [January 31, 2024, 10:34am UTC](https://builder.metamask.io/t/archive-how-get-public-key-from-a-wallet-using-custom-auth-verifier/1628/3 "2024-01-31T10:34:59Z")

</div>

Thanks for your patience.

You can get the idToken from Web3Auth by calling `authenticateUser()` function and  
decode the idToken to get the wallet-\> public\_key

You may refer to the below documentation for the sample payload for social login and external wallets

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

```
  <a href="https://web3auth.io/docs/pnp/features/server-side-verification/social-login-users#sample-idtoken-payload" target="_blank" rel="noopener">web3auth.io</a>

```

### [Social Login Users | Documentation | Web3Auth](https://web3auth.io/docs/pnp/features/server-side-verification/social-login-users#sample-idtoken-payload)

Social Login Users | Documentation - Web3Auth

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

```
  <a href="https://web3auth.io/docs/pnp/features/server-side-verification/external-wallets#sample-idtoken-payload" target="_blank" rel="noopener">web3auth.io</a>

```

### [External Wallets | Documentation | Web3Auth](https://web3auth.io/docs/pnp/features/server-side-verification/external-wallets#sample-idtoken-payload)

External Wallets | Documentation - Web3Auth

---

<div class="post-metadata">

**Author:** ![vjgee](https://avatars.discourse-cdn.com/v4/letter/v/b5e925/32.png) [@vjgee](https://builder.metamask.io/u/vjgee)\
**Post date:** [February 1, 2024, 9:38am UTC](https://builder.metamask.io/t/archive-how-get-public-key-from-a-wallet-using-custom-auth-verifier/1628/4 "2024-02-01T09:38:33Z")

</div>

@rsaquicela Are you able to see my previous message? You need to decode the idToken to get the wallet public\_key.

---

<div class="post-metadata">

**Author:** ![rsaquicela](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@rsaquicela](https://builder.metamask.io/u/rsaquicela)\
**Post date:** [February 1, 2024, 5:30pm UTC](https://builder.metamask.io/t/archive-how-get-public-key-from-a-wallet-using-custom-auth-verifier/1628/5 "2024-02-01T17:30:43Z")

</div>

Hello, Yes i read it.

But, I’m using custom auth verifier.

DOC:

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

```
  <a href="https://web3auth.io/docs/auth-provider-setup/byo-jwt-providers" target="_blank" rel="noopener">web3auth.io</a>

```

### [Bring your own custom JWT Providers | Documentation | Web3Auth](https://web3auth.io/docs/auth-provider-setup/byo-jwt-providers)

Bring your own custom JWT Providers | Documentation - Web3Auth

So the method `authenticateUser` not exists.

---

<div class="post-metadata">

**Author:** ![vjgee](https://avatars.discourse-cdn.com/v4/letter/v/b5e925/32.png) [@vjgee](https://builder.metamask.io/u/vjgee)\
**Post date:** [February 2, 2024, 3:12am UTC](https://builder.metamask.io/t/archive-how-get-public-key-from-a-wallet-using-custom-auth-verifier/1628/6 "2024-02-02T03:12:08Z")

</div>

@rsaquicela Ok, we will get back with further updates on how to do this.

---

<div class="post-metadata">

**Author:** ![vjgee](https://avatars.discourse-cdn.com/v4/letter/v/b5e925/32.png) [@vjgee](https://builder.metamask.io/u/vjgee)\
**Post date:** [February 2, 2024, 1:45pm UTC](https://builder.metamask.io/t/archive-how-get-public-key-from-a-wallet-using-custom-auth-verifier/1628/7 "2024-02-02T13:45:39Z")

</div>

@rsaquicela You can use this code snippet for eth\_public\_key:

```auto
const eth_private_key = await provider.request({ method: “eth_private_key” });
console.log("ETH PrivateKey: ", eth_private_key);
const eth_public_key = await provider.request({ method: “eth_public_key” });
console.log("ETH PublicKey: ", eth_public_key);
const eth_address = await provider.request({ method: “eth_accounts” });
console.log("ETH Address: ", eth_address[0]);

```

---

<div class="post-metadata">

**Author:** ![rsaquicela](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@rsaquicela](https://builder.metamask.io/u/rsaquicela)\
**Post date:** [February 5, 2024, 3:05pm UTC](https://builder.metamask.io/t/archive-how-get-public-key-from-a-wallet-using-custom-auth-verifier/1628/8 "2024-02-05T15:05:03Z")

</div>

> [@vjgee](#):
>
> ```auto
> const eth_public_key = await provider.request({ method: “eth_public_key” });
> console.log("ETH PublicKey: ", eth_public_key);
> 
> ```

**Yes, I used it but I get an error:**

```auto
**node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

```

---

<div class="post-metadata">

**Author:** ![TomTom](https://avatars.discourse-cdn.com/v4/letter/t/a9a28c/32.png) [@TomTom](https://builder.metamask.io/u/TomTom)\
**Post date:** [February 5, 2024, 5:55pm UTC](https://builder.metamask.io/t/archive-how-get-public-key-from-a-wallet-using-custom-auth-verifier/1628/9 "2024-02-05T17:55:03Z")

</div>

Hi @rsaquicela,

“eth\_public\_key” is not an JSON RPC method.

You can see the list of methods in this link: [JSON-RPC API | ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc)

If you are looking for the public address, you should do :

const ethAddress = await provider.request({ method: “eth\_accounts” });  
console.log("ETH Address: ", eth\_address);

Please contact me if the problem persist.
