You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to make a Spotify Clone using the Spotify API. For this im using Auth.js v5, where im trying to automatically refresh the access token when it expires (for testing purposes it does it every 30 seconds in my code for now).
However the problem with this is that when you call the Spotify refresh endpoint, it invalidates your refresh_token after using it. And since the callback in the auth.js file is called like 6 times on every render (can someone also explain why this happens), it fails of the last 5 attempts and return this:
I tried using Supabase Auth instead, and i notices that when i use the access_token i get back from them, i'm not getting a new refresh_token in the response when refreshing the token, and i can keep using the same refresh token.
Response when using access token with Supabase Auth:
I believe that getting this behaviour with Auth.js would resolve my issue. Does any of you know what Supabase Auth is doing for getting an infinitely reusable refresh_token?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to make a Spotify Clone using the Spotify API. For this im using Auth.js v5, where im trying to automatically refresh the access token when it expires (for testing purposes it does it every 30 seconds in my code for now).
I found this Reddit post, where someone has made something that seemingly worked for him with an older version of the next-auth library:
https://www.reddit.com/r/nextjs/comments/10o6aup/next_auth_spotify_reauthentication_access_token/
However the problem with this is that when you call the Spotify refresh endpoint, it invalidates your refresh_token after using it. And since the callback in the auth.js file is called like 6 times on every render (can someone also explain why this happens), it fails of the last 5 attempts and return this:
Succesful response:
Error response:
I tried using Supabase Auth instead, and i notices that when i use the access_token i get back from them, i'm not getting a new refresh_token in the response when refreshing the token, and i can keep using the same refresh token.
Response when using access token with Supabase Auth:
I believe that getting this behaviour with Auth.js would resolve my issue. Does any of you know what Supabase Auth is doing for getting an infinitely reusable refresh_token?
My current code looks like this:
SignIn function:
auth.js file:
Beta Was this translation helpful? Give feedback.
All reactions