Skip to content

Commit 3f4bbe4

Browse files
committed
Update getIdentityToken function
1 parent 85fe1c6 commit 3f4bbe4

6 files changed

Lines changed: 22 additions & 22 deletions

File tree

docs/features/server-side-verification.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ To implement server-side verification with Web3Auth:
3939
## Getting the ID Token
4040

4141
After a user is logged in using one of the supported Wallets, One can obtain the `idToken` by
42-
calling the `authenticateUser` function of Web3Auth.
42+
calling the `getIdentityToken` function of Web3Auth.
4343

4444
```tsx
45-
await web3auth.authenticateUser();
45+
await web3auth.getIdentityToken();
4646
```
4747

4848
#### Returns
@@ -205,7 +205,7 @@ By default, Web3Auth returns an `idToken` which contains the `public_key` in the
205205
## Social Login Verification
206206

207207
In order to verify the JWT Token(`idToken`) you'll need the compressed **app_pub_key** (derived from
208-
_**app_scoped_privkey**_) and the `idToken` obtained from the `authenticateUser` function in your
208+
_**app_scoped_privkey**_) and the `idToken` obtained from the `getIdentityToken` function in your
209209
frontend.
210210

211211
### Getting `app_pub_key` and `idToken`
@@ -261,7 +261,7 @@ const user = await web3auth.getUserInfo();
261261

262262
/*
263263
OR
264-
const token = await web3auth.authenticateUser();
264+
const token = await web3auth.getIdentityToken();
265265
*/
266266

267267
// Verify idToken at your backend server
@@ -323,7 +323,7 @@ if ((jwtDecoded.payload as any).wallets.find((x: { type: string }) => x.type ===
323323
## External Wallet Verification
324324
325325
To verify the JWT Token(`idToken`) you need the wallet `address` and the `idToken` obtained from the
326-
`authenticateUser()` function in your frontend.
326+
`getIdentityToken()` function in your frontend.
327327
328328
### Getting `address` and `idToken`
329329
@@ -338,7 +338,7 @@ const address = await solanaWallet.requestAccounts();
338338
// For other chains, please refer to https://web3auth.io/docs/connect-blockchain/
339339

340340
/* Assuming user is logged in, get the token containtaing idToken */
341-
const token = await web3auth.authenticateUser();
341+
const token = await web3auth.getIdentityToken();
342342

343343
// Verify idToken at your backend server
344344
const res = await fetch("/api/verify", {

docs/sdk/web/js/functions/functions.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ page for each function.
3131
| Function Name | Description |
3232
| -------------------- | ----------------------------------------------------------- |
3333
| `getUserInfo()` | Retrieves the authenticated user's information. |
34-
| `authenticateUser()` | Gets the idToken from Web3Auth for authentication purposes. |
34+
| `getIdentityToken()` | Gets the idToken from Web3Auth for authentication purposes. |
3535

3636
### Security Functions
3737

docs/sdk/web/js/functions/authenticateUser.mdx renamed to docs/sdk/web/js/functions/getIdentityToken.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: authenticateUser
3-
sidebar_label: authenticateUser
4-
description: "@web3auth/modal authenticateUser | Documentation - Web3Auth"
2+
title: getIdentityToken
3+
sidebar_label: getIdentityToken
4+
description: "@web3auth/modal getIdentityToken | Documentation - Web3Auth"
55
---
66

77
import TabItem from "@theme/TabItem";
@@ -21,7 +21,7 @@ stored anywhere and are fetched from the adapter during the connection and remai
2121
```ts
2222
// Later in your code:
2323
try {
24-
const idToken = await web3auth.authenticateUser();
24+
const idToken = await web3auth.getIdentityToken();
2525
console.log(idToken);
2626
} catch (error) {
2727
console.error("Error authenticating user:", error);
@@ -31,7 +31,7 @@ try {
3131
### Return Type
3232

3333
```typescript
34-
authenticateUser(): Promise<UserAuthInfo>
34+
getIdentityToken(): Promise<UserAuthInfo>
3535

3636
type UserAuthInfo = { idToken: string };
3737
```
@@ -78,7 +78,7 @@ The `idToken` is a JWT that can be decoded to get user information.
7878

7979
<TabItem value="type">
8080

81-
`authenticateUser(): Promise<UserAuthInfo>`
81+
`getIdentityToken(): Promise<UserAuthInfo>`
8282

8383
```tsx
8484
export type UserAuthInfo = { idToken: string };
@@ -137,7 +137,7 @@ export type UserAuthInfo = { idToken: string };
137137

138138
<TabItem value="type">
139139

140-
`authenticateUser(): Promise<UserAuthInfo>`
140+
`getIdentityToken(): Promise<UserAuthInfo>`
141141

142142
```tsx
143143
export type UserAuthInfo = { idToken: string };
@@ -172,7 +172,7 @@ export type UserAuthInfo = { idToken: string };
172172

173173
```javascript
174174
try {
175-
const userInfo = await web3auth.authenticateUser();
175+
const userInfo = await web3auth.getIdentityToken();
176176
// Use the token
177177
} catch (error) {
178178
// Handle errors (e.g., user not connected, network issues)

docs/sdk/web/react/hooks/useIdentityToken.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import { useIdentityToken } from "@web3auth/modal/react";
1818
import { useIdentityToken } from "@web3auth/modal/react";
1919

2020
function IdentityTokenButton() {
21-
const { authenticateUser, loading, error, token } = useIdentityToken();
21+
const { getIdentityToken, loading, error, token } = useIdentityToken();
2222

2323
return (
2424
<div>
25-
<button onClick={() => authenticateUser()} disabled={loading}>
25+
<button onClick={() => getIdentityToken()} disabled={loading}>
2626
{loading ? "Authenticating..." : "Get Identity Token"}
2727
</button>
2828
{token && <div>Token: {token}</div>}
@@ -56,7 +56,7 @@ Error that occurred during the authentication process.
5656

5757
The identity token returned after successful authentication.
5858

59-
#### authenticateUser
59+
#### getIdentityToken
6060

6161
`() => Promise<string | null>`
6262

docs/sdk/web/vue/composables/useIdentityToken.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ import { useIdentityToken } from "@web3auth/modal/vue";
1818
<script setup lang="ts">
1919
import { useIdentityToken } from "@web3auth/modal/vue";
2020
21-
const { authenticateUser, loading, error, token } = useIdentityToken();
21+
const { getIdentityToken, loading, error, token } = useIdentityToken();
2222
</script>
2323

2424
<template>
2525
<div>
26-
<button @click="authenticateUser" :disabled="loading">
26+
<button @click="getIdentityToken" :disabled="loading">
2727
{{ loading ? "Authenticating..." : "Get Identity Token" }}
2828
</button>
2929
<div v-if="token">Token: {{ token }}</div>
@@ -56,7 +56,7 @@ Error that occurred during the authentication process.
5656

5757
The identity token returned after successful authentication.
5858

59-
#### authenticateUser
59+
#### getIdentityToken
6060

6161
`() => Promise<string | null>`
6262

sidebars.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,9 +739,9 @@ const sidebars: SidebarsConfig = {
739739
label: "Functions",
740740
items: [
741741
"sdk/web/js/functions/functions",
742-
"sdk/web/js/functions/authenticateUser",
743742
"sdk/web/js/functions/connect",
744743
"sdk/web/js/functions/enableMFA",
744+
"sdk/web/js/functions/getIdentityToken",
745745
"sdk/web/js/functions/getUserInfo",
746746
"sdk/web/js/functions/logout",
747747
"sdk/web/js/functions/manageMFA",

0 commit comments

Comments
 (0)