gardner / react-oauth2-pkce

React auth provider that works with AWS cognito PKCE🛡️🔒
49 stars 57 forks source link

Property 'authTokens' does not exist on type 'AuthContextProps'. #17

Open tyteen4a03 opened 3 years ago

tyteen4a03 commented 3 years ago

The example references this:

  const { authService, authTokens } = useAuth();

but authTokens doesn't exist on the object returned by useAuth.

Goethe0 commented 3 years ago

yeah, I changed the code to const authTokens = authService.getAuthTokens() and authTokens.idTokens to authTokens.id_token, but still didn't work, the example didn't even load.

altenfreelance commented 2 years ago

The example is out of date it seems. @Goethe0 comment above resolved the issue for me.

` const { authService } = useAuth() const [authTokens, setAuthTokens] = useState(null)

useEffect(() => { console.log(authTokens) if (authService.isAuthenticated()) { setAuthTokens(authService.getAuthTokens()) } }, [authService.isAuthenticated()]) `

gardner commented 2 years ago

I'll have a look at the example. It hasn't been been updated in a while.