Laravel Passport Client Credentials Grant Tokens with Nuxt

I have a Laravel Api with Passport, I put the Client Credentials Grant Tokens and everything works fine from Laravel Side, now I can't find the best way to consume the Api from Nuxt SSR.

I already implement the API in my Nuxt Pages and Components, but, now I do not how to manage the token, I already use nuxtServerInit and get the token, but, I can't put if setToken in Axios Plugin, I use the store, but in the Axios plugin comes empty, then I use a cookie, the first time is set the token, but when the token expire I get the 401 status, now, I do not how to refresh the token without refresh the page and verify in any request of axios and refreshing. I try the axios interceptors but not working.

I am trying to use @nuxt/auth but can't find the best approach. I use private runtime config in nuxt to manage the client_id, client_secret to not be exposed to the client.

Anybody can help?

Read more here:

Content Attribution

This content was originally published by Jonathan at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: