diff --git a/packages/react/src/AsgardeoReactClient.ts b/packages/react/src/AsgardeoReactClient.ts index 85d494f4..88d1b089 100644 --- a/packages/react/src/AsgardeoReactClient.ts +++ b/packages/react/src/AsgardeoReactClient.ts @@ -158,6 +158,12 @@ class AsgardeoReactClient e return this.asgardeo.getDecodedIdToken(sessionId); } + async getIdToken(): Promise { + return this.withLoading(async () => { + return this.asgardeo.getIdToken(); + }); + } + async getUserProfile(options?: any): Promise { return this.withLoading(async () => { try { diff --git a/packages/react/src/contexts/Asgardeo/AsgardeoContext.ts b/packages/react/src/contexts/Asgardeo/AsgardeoContext.ts index 03a40f7a..933b3085 100644 --- a/packages/react/src/contexts/Asgardeo/AsgardeoContext.ts +++ b/packages/react/src/contexts/Asgardeo/AsgardeoContext.ts @@ -113,6 +113,14 @@ export type AsgardeoContextProps = { */ getDecodedIdToken: () => Promise; + /** + * Function to retrieve the ID token. + * This function retrieves the ID token and returns it. + * + * @returns A promise that resolves to the ID token. + */ + getIdToken: () => Promise; + /** * Retrieves the access token stored in the storage. * This function retrieves the access token and returns it. @@ -167,6 +175,7 @@ const AsgardeoContext: Context = createContext> = ({ return await asgardeo.getDecodedIdToken(); }, [asgardeo]); + const getIdToken = useCallback(async (): Promise => { + return await asgardeo.getIdToken(); + }, [asgardeo]); + const getAccessToken = useCallback(async (): Promise => { return await asgardeo.getAccessToken(); }, [asgardeo]); @@ -576,6 +580,7 @@ const AsgardeoProvider: FC> = ({ reInitialize, signInOptions, getDecodedIdToken, + getIdToken, exchangeToken, syncSession, platform: config?.platform,