Skip to content

Commit

Permalink
Merge pull request #38 from mchr3k/main
Browse files Browse the repository at this point in the history
Add getIdToken method
  • Loading branch information
DaveOrDead authored Jan 31, 2024
2 parents 9c1f6af + b4319c7 commit fc332ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/state/KindeContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface KindeContextProps extends State {
getPermission: KindeClient['getPermission'];
getOrganization: KindeClient['getOrganization'];
getToken: KindeClient['getToken'];
getIdToken: KindeClient['getIdToken'];
getUser: KindeClient['getUser'];
getUserOrganizations: KindeClient['getUserOrganizations'];
}
Expand Down
12 changes: 12 additions & 0 deletions src/state/KindeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,21 @@ export const KindeProvider = ({
return token;
}, [client]);

const getIdToken = useCallback(async () => {
let idToken;
try {
idToken = await client!.getIdToken();
} catch (error) {
throw console.error(error);
}
return idToken;
}, [client]);

const contextValue = useMemo(() => {
return {
...state,
getToken,
getIdToken,
login,
register,
logout,
Expand All @@ -187,6 +198,7 @@ export const KindeProvider = ({
}, [
state,
getToken,
getIdToken,
login,
register,
logout,
Expand Down

0 comments on commit fc332ee

Please sign in to comment.