Giter VIP home page Giter VIP logo

Comments (2)

adamjmcgrath avatar adamjmcgrath commented on June 16, 2024 3

Hey @dillonco - using auth0-react shouldn't make a difference since it's using spa js under the hood

we couldn't get the isAuthenticated to ever return True.

This is usually a mismatch between what you're saving to localStorage in your Cypress code (which should look something like https://github.com/adamjmcgrath/cypress-spa-example/blob/master/cypress/integration/example.spec.js#L33) and what auth0-react (via spa js) is looking for in localStorage when it checks if you're authenticated.

To debug, put something like this at the top of your page

<script>
    var __getItem = localStorage.getItem.bind(localStorage);
    localStorage.getItem = function (key) {
      console.log('looking for', key, 'in', Object.keys(localStorage));
      return __getItem(key);
    };
  </script>

This should log something like this to your console:

looking for @@auth0spajs@@::xyzabc::default::openid profile email in ["@@auth0spajs@@::xyzabc::default::openid profile email", "ally-supports-cache"]

The cache key format is @@auth0spajs@@::CLIENT_ID::AUDIENCE::SCOPE, if the key your looking for doesn't quite match the one in the list - you'll need to update the CLIENT_ID, AUDIENCE or SCOPE in your Cypress code or where you've invoked <Auth0Provider>

If the list doesn't have anything like that in it, you haven't logged in succesfully.

If the console doesn't log anything, check you're using cacheLocation="localstorage" in your Auth0Provider (you need to do this at least under test)

from cypress-spa-example.

dillonco avatar dillonco commented on June 16, 2024 1

That's exactly what I needed to know, thank you!

from cypress-spa-example.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.