Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/react/src/AsgardeoReactClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ class AsgardeoReactClient<T extends AsgardeoReactConfig = AsgardeoReactConfig> e
return this.asgardeo.getDecodedIdToken(sessionId);
}

async getIdToken(): Promise<string> {
return this.withLoading(async () => {
return this.asgardeo.getIdToken();
});
}

async getUserProfile(options?: any): Promise<UserProfile> {
return this.withLoading(async () => {
try {
Expand Down
9 changes: 9 additions & 0 deletions packages/react/src/contexts/Asgardeo/AsgardeoContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ export type AsgardeoContextProps = {
*/
getDecodedIdToken: () => Promise<IdToken>;

/**
* 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<string>;

/**
* Retrieves the access token stored in the storage.
* This function retrieves the access token and returns it.
Expand Down Expand Up @@ -167,6 +175,7 @@ const AsgardeoContext: Context<AsgardeoContextProps | null> = createContext<null
},
signInOptions: {},
getDecodedIdToken: null,
getIdToken: null,
getAccessToken: null,
exchangeToken: null,
storage: 'sessionStorage',
Expand Down
5 changes: 5 additions & 0 deletions packages/react/src/contexts/Asgardeo/AsgardeoProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,10 @@ const AsgardeoProvider: FC<PropsWithChildren<AsgardeoProviderProps>> = ({
return await asgardeo.getDecodedIdToken();
}, [asgardeo]);

const getIdToken = useCallback(async (): Promise<string> => {
return await asgardeo.getIdToken();
}, [asgardeo]);

const getAccessToken = useCallback(async (): Promise<string> => {
return await asgardeo.getAccessToken();
}, [asgardeo]);
Expand Down Expand Up @@ -576,6 +580,7 @@ const AsgardeoProvider: FC<PropsWithChildren<AsgardeoProviderProps>> = ({
reInitialize,
signInOptions,
getDecodedIdToken,
getIdToken,
exchangeToken,
syncSession,
platform: config?.platform,
Expand Down
Loading