SunoAI-API / Suno-API

Create Music in Seconds with SunoAPI.
MIT License
1.49k stars 223 forks source link

Did Suno change the way the session and cookie is logged? #24

Closed EA914 closed 7 months ago

EA914 commented 7 months ago

All of the sudden my code stopped working today and I am getting "unauthorized" as an error message. I re-added the session ID and cookie, but it is still not working.

Can you try your code and try to hit the Suno AI API and let me know if something changed?

alessandro-newzoo commented 7 months ago

Did you make sure to get your session and cookie from a new session or did you have it stored somewhere? Once you update your env variables remember that you usually have to redeploy.

Anyway, I also got "unauthorized" on Friday afternoon (which is a week after I set this up for the first time), then went on the website and noticed I got logged out. That means my Suno cookies had expired, and in theory this app should renew them automatically, but it didn't.

I then regrabbed cookie and session from touch?_clerk_js_version=..., updated my env variables, redeployed, and now it worked again. Though it's annoying that I'm gonna have to do it every week now :/ Hopefully they'll fix it.

EA914 commented 7 months ago

When you say redeploy, what exactly do you mean?

And when I check for the clerk cookie or even token I see multiple values of cookies on each one so I'm not sure which one to use now

alessandro-newzoo commented 7 months ago

When you say redeploy, what exactly do you mean?

I mean that after you update the .env file (or wherever you're storing Cookie and session), if you're running it on some online platform (like DigitalOcean Apps), you'll need to redeploy the project to apply the new env variables. There's usually a button for that somewhere, depending on what platform you're deploying this on.

If you're running it on your machine then I'd try stopping it and reinstalling it:

And when I check for the clerk cookie or even token I see multiple values of cookies on each one so I'm not sure which one to use now

If you scroll towards the end of the Headers tab you'll find it. It's the only one that's called just Cookie:

CleanShot 2024-04-21 at 23 45 23@2x note that you might not have the __stripe_mid part if you don't have a paid plan

I've also noticed that different Network calls seem to show different cookies... Maybe try grabbing it from other calls too (tokens?_clerk_js_version=, touch?_clerk_js_version=, client?_clerk_js_version=) if that doesn't work.

It'd be helpful if they documented this a bit better as I'm not really sure how the auto-renew is supposed to work, and where exactly you need to get your cookies.

EA914 commented 7 months ago

Perfect! Got it to work again. Thank you!