Nextjs-auth0: AccessTokenError When Re-fetching User Profile

Created on 20 Jul 2020  路  11Comments  路  Source: auth0/nextjs-auth0

Please do not report security vulnerabilities here. The Responsible Disclosure Program details the procedure for disclosing security issues.

Thank you in advance for helping us to improve this library! Please read through the template below and answer all relevant questions. Your additional work here is greatly appreciated and will help us respond as quickly as possible. For general support or usage questions, use the Auth0 Community or Auth0 Support. Finally, to avoid duplicates, please search existing Issues before submitting one here.

By submitting an Issue to this repository, you agree to the terms within the Auth0 Code of Conduct.

Description

Using your examples I was at the point of getting the user profile, and I wanted to test the re-fetch feature as I plan on using it in my final app. When I do not have the refetch option turned on the API returns as expected, but when I turn it on I get the error:

AccessTokenError: The user does not have a valid access token.

My setup is literally a copy/paste of the example code just with my values put in where needed.

Reproduction

For me it was just follow the examples in the main Readme while using the NextJS - Tailwind template.

Environment

Please provide the following:

  • Version of this library used: ^0.15.0
  • Version of the platform or framework used, if applicable:"next": "^9.2.0", "react": "^16.12.0"
  • Other relevant versions (language, server software, OS, browser): Pop-OS (Ubuntu), server side issue on Node v12.18.1
  • Other modules/plugins/libraries that might be involved:
{
  "name": "auth0-test",
  "version": "1.0.0",
  "scripts": {
    "dev": "next",
    "build": "next build",
    "start": "next start"
  },
  "dependencies": {
    "@auth0/nextjs-auth0": "^0.15.0",
    "next": "^9.2.0",
    "react": "^16.12.0",
    "react-dom": "^16.12.0"
  },
  "devDependencies": {
    "@fullhuman/postcss-purgecss": "^2.3.0",
    "autoprefixer": "^9.8.5",
    "postcss-preset-env": "^6.7.0",
    "tailwindcss": "^1.4.0"
  }
}

needs investigation

Most helpful comment

@Widcket I moved to SPA auth0-react because back in the days this plugin had too many flaws. But I will definitely give it another go, hopefully I find the time for it this week

All 11 comments

Any help in understanding why this is happening would be greatly appreciated. Otherwise most things seem fine.

Edit: I get the same thing when testing the Calling an API section as well, so I'm obviously missing something key.

maybe related to https://github.com/auth0/nextjs-auth0/issues/140. may need to set storeAccessToken: true on config :)

@joecris storeAccessToken:true fixed it for me. But the refetch:true is not fetching the user account for me. Its still the old app_metadata

Hi, can you please check if this issue still happens with the 1.0.0 beta? We completely reworked the session logic, so this may no longer be the case.

@Widcket Personally I've moved to another stack for my application. Would you prefer I close this or leave this open for @dohomi to continue tracking on their feedback?

@firrae I'll leave this open to track @dohomi's issue. Thanks

@Widcket I moved to SPA auth0-react because back in the days this plugin had too many flaws. But I will definitely give it another go, hopefully I find the time for it this week

Ironic, I might actually be back to using it soon enough as well. So if I run into this again I'll return.

Closing this due to inactivity @dohomi - feel free to ping me to reopen this or raise another issue if you want to discuss anything further

@adamjmcgrath Is there an ETA when the first stable release is going to land? I will have a new project starting in the next very few weeks and the scope will be NextJS and Auth0 again. This time I'd consider this project over the SPA version if it outgrows the experimental status (the project needs to go life within 2-3 months).

@dohomi the 1.0.0 GA release is out now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shansmith01 picture shansmith01  路  4Comments

ichtestemalwieder picture ichtestemalwieder  路  3Comments

pasenidis picture pasenidis  路  4Comments

platocrat picture platocrat  路  3Comments

mustafaKamal-fe picture mustafaKamal-fe  路  5Comments