Hey, I’m new to Auth0.
I managed to make the react and javascript sample work but now I need to make it work for ExtJs.
The login seems to work but the isAuthenticated returns always false.
The app is going in a loop : isAuthenticated = false → Login → already logged → IsAuthenticated = false → …
Probably a code issue as the application settings in auth0 works for the sample apps.
Edit : auth0.user is undefined
             
            
              
              
              
            
            
           
          
            
            
              You will need to use the auth0.handleRedirectCallback() function to handle success and error responses from Auth0.
try {
    auth0.isAuthenticated().then(async function (authenticated) {
        if (!authenticated) {
            const query = window.location.search;
            const shouldParseResult = query.includes("code=") && query.includes("state=");
            if (shouldParseResult) {
                console.log("> Parsing redirect");
                try {
                    const result = await auth0.handleRedirectCallback();
                    console.log("Logged in!");
                } catch (err) {
                    console.log("Error parsing redirect:", err);
                }
                window.history.replaceState({}, document.title, "/");
            } else {
                auth0.loginWithRedirect({ redirect_uri: window.location.origin });
            }
        } else {
            auth0.getTokenSilently().then(function (token) {
                Ext.Ajax.setDefaultHeaders({ 'Authorization': 'Bearer ' + token });
            });
        }
    })
} catch (err) {
    console.log("Log in failed", err);
}
Alternatively, you can the useloginWithPopup() function:
if(!authenticated) {                      
    auth0.loginWithPopup().then(token => {
        auth0.getUser().then(user => {
            console.log(user);
        });
    })
 }
             
            
              
              
              1 Like
            
                
            
           
          
            
            
              Thanks for helping on this one Art!