Skip to content

Commit

Permalink
feat(go): use acces token instead of ID token
Browse files Browse the repository at this point in the history
  • Loading branch information
MikaelVallenet committed May 19, 2023
1 parent 499a8e4 commit b6a3143
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
16 changes: 7 additions & 9 deletions web/src/components/ProtectedRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,23 @@ const ProtectedRoute = ({ component: Component, ...rest }) => {
isLoading,
isAuthenticated,
loginWithRedirect,
getIdTokenClaims,
getAccessTokenSilently,
} = useAuth0()

if (!isLoading && !isAuthenticated) {
loginWithRedirect({
scope: "openid profile email",
})
.then(() => {getIdTokenClaims()
.then(() => {getAccessTokenSilently()
.then((token) => {
console.log(token.__raw);
console.log("email : ", token.email_verified);
dispatch(setAuthSession(token.__raw))
console.log(token);
dispatch(setAuthSession(token))
})
})
} else if (!isLoading && isAuthenticated && !userSession.accessToken) {
getIdTokenClaims().then((token) => {
console.log(token.__raw);
console.log("email : ", token.email_verified);
dispatch(setAuthSession(token.__raw))
getAccessTokenSilently().then((token) => {
console.log(token);
dispatch(setAuthSession(token))
})
}

Expand Down
3 changes: 2 additions & 1 deletion web/src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const Index = () => {
domain="dev-5ccwzy8qtcsjsnpf.us.auth0.com"
clientId="bJpLWOLTRseEVfM9kvFhKfi9wUBmm8Gh"
authorizationParams={{
redirect_uri: window.location.origin
redirect_uri: window.location.origin,
audience: "https://pathwar.net/"
}}
>
<ThemeProvider theme={themeToUse}>
Expand Down

0 comments on commit b6a3143

Please sign in to comment.