chapter-three / next-drupal

Next.js for Drupal has everything you need to build a next-generation front-end for your Drupal site: SSG, SSR, and ISR, Multi-site, Authentication, Webforms, Search API, I18n and Preview mode (works with JSON:API and GraphQL).
https://next-drupal.org
MIT License
601 stars 172 forks source link

OAuth token expires #765

Open reinvanoyen opened 1 month ago

reinvanoyen commented 1 month ago

Package

next-drupal (NPM package)

Ask the question

Hi all,

We're using next-drupal 1.6.0 in our next 14.2.2 project. Our JSON:API uses oauth for authentication. This is how we initialise our DrupalClient:

new DrupalClient(DRUPAL_BASE_URL, {
     apiPrefix: "/api",
     auth: {
          clientId: DRUPAL_CLIENT_ID,
          clientSecret: DRUPAL_CLIENT_SECRET,
          url: `/oauth/token`,
     },
});

Now, unfortunately when using the endpoints on runtime, we get expired tokens after a while, causing our application to crash. We proceeded by using SSG for most parts of website and that works like a charm. Of course it's a requirement for some features to be able to fetch resources on the go, has anyone had any problems with this?

Are there any reported issues on token refreshing not working? Is this desired behavior?

Additional context

next-drupal 1.6.0 next 14.2.2

MontiMarco92 commented 5 days ago

I've also experienced this expiration token issue, causing drupal to return "Unauthorized" access for various resource calls. It think it might be related to the Next js 14 caching system, however I haven't seem able to pinpoint the problem and fix it.