@auth0/auth0-spa-js createAuth0Client
method takes over 5 seconds to complete every time a user logs in. Even after waiting, getTokenSiliently
also takes another 5 seconds. That seems ridiculous on a high speed internet, is it normal? (code below, please excuse the lazy perf checking)
The provider is passed proper credentials, redirect_uri
useEffect(() => {
const initAuth0 = async () => {
console.log('I still run!!!')
const now = Date.now();
console.log('starting login', now);
const auth0FromHook = await createAuth0Client(initOptions);
console.log('created client', Date.now() - now)
setAuth0(auth0FromHook);
if (window.location.search.includes('code=')) {
console.log('calling redirect')
const { appState } = await auth0FromHook.handleRedirectCallback();
onRedirectCallback(appState);
}
const isAuthenticatedP = auth0FromHook.isAuthenticated();
const tokenP = auth0FromHook.getTokenSilently();
const isAuthenticated = await isAuthenticatedP;
console.log('is authenticated', isAuthenticated, Date.now() - now);
setIsAuthenticated(isAuthenticated);
if (isAuthenticated) {
const token = await tokenP;
const user = await auth0FromHook.getUser();
console.log('got tokes', Date.now() - now);
const meteorStart = Date.now();
console.log('starting call to meteor login', meteorStart);
Meteor.loginWithIntelage({ token }, () => {
const meteorUser = Meteor.user();
const combinedUserData = { ...user, ...meteorUser };
console.log('finish call to meteor', Date.now() - meteorStart);
console.log('metoer user', meteorUser, loggingIn);
console.log('user', user);
setUser(combinedUserData);
setLoading(false);
});
} else {
// redirect
console.log('redirecting!')
auth0FromHook.loginWithRedirect({});
}
console.log('finish auth', Date.now() - now);
};
initAuth0();
}, []);