-
Notifications
You must be signed in to change notification settings - Fork 3.9k
-
I have copied the code from spotify-auth and keep receving the error "Error in the token Function: Error: State cookie not set or expired. Maybe you took too long to authorize. Please try again." after clicking the sign in with spotify button. I checked the log and it says the verification state is undefined.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
The error message suggests a problem with the state cookie not being set or expired. Several reasons could cause this issue.
Possible Solutions:
-
Timed Out: Make sure you're not taking too long between initiating the auth request and completing it.
-
Cookie Policy: Ensure your browser's cookie policy allows third-party cookies, or at least allows cookies from Spotify.
-
Check State: Validate that the 'state' parameter is being set correctly when you initially redirect to Spotify's authorization endpoint and that it is also present in the callback URL.
-
Logs: Look at server logs to understand if the 'state' parameter is being read correctly. If 'undefined', it indicates the state is not being passed back by Spotify or not being read correctly on your end.
-
Code Issue: There could be a bug in how you've implemented the Spotify Auth code. Ensure you're following the Spotify Authorization Guide closely.
-
Library Issue: If you're using a third-party library for Spotify authentication, consider checking its documentation or GitHub issues for similar problems.
-
Same Site Policy: Make sure that your server, where the cookie is set, and the client, where the cookie is read, follow the same-origin policy.
-
Server Restart: If you are storing the 'state' parameter in the server memory, it will get lost if the server restarts.
-
Debug: Put logging statements at crucial points to trace how the 'state' parameter is being set and read.
Feel free to respond with additional information if you're still facing issues.
Beta Was this translation helpful? Give feedback.