next-drupal icon indicating copy to clipboard operation
next-drupal copied to clipboard

OAuth token expires

Open reinvanoyen opened this issue 1 year ago • 1 comments

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

reinvanoyen avatar May 23 '24 11:05 reinvanoyen

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.

MontiMarco92 avatar Jul 05 '24 08:07 MontiMarco92

I've also encountered this issue with next-drupal 2.0.0. Any workarounds?

boazpoolman avatar Aug 28 '25 08:08 boazpoolman

I think this is the same issue as: #788

bojanbogdanovic avatar Sep 12 '25 10:09 bojanbogdanovic