After a day of searching, I came close to understand that while ‘loading’ is true, the function won’t return anything so it is undefined.
Writing something like if (!loading) { const accessTokenData = await getTokenSilently(); would solve this but it doesn’t.
Also refreshing the page will give the error but if I don’t refresh but change a code somewhere so it will compile without reloading, function works perfectly.
I believe I have a similar issue when using the new Vue3 SDK using authGuard to protect a Vue router route. I get the following error: [Vue warn]: Error in mounted hook: "TypeError: Cannot read properties of undefined (reading 'getAccessTokenSilently')"
I am following the instructions in the README, except I have the Home page protected by the guard, so I assume it is giving issues because of timing.
I got same issue in vue 3 using auth0-vue sdk, I call getAccessTokenSilently in a Typescipt file, seems that getAccessTokenSilently only works in vue file
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘getAccessTokenSilently’)