Announcements

Help Wizard

Step 1

NEXT STEP

Spotify api returning incorrect us aer access token after apple login

Spotify api returning incorrect us aer access token after apple login

Plan

Free/Premium

Country

Canada

Device

iphone 16, M3 pro

Operating System

IOS, MacOS

 

My Question or Issue

 

Hi everyone,

I’m running into a strange issue with Spotify OAuth in my Next.js app. The flow works perfectly when logging into Spotify with a regular username and password. However, when logging in via Apple or Google, the Spotify auth seems to succeed, but the page either crashes or shows a blank screen. On Vercel, I see the following error in the logs:

 

TypeError: Body is unusable: Body has already been read
at c (.next/server/app/api/callback/route.js:1:1837)


while the client reads:
{"error": "invalid grant"
, "error_description"
: " In
valid authorization code"}}


i think it has something to so with

Authorization codes being reused or becoming invalid
Something different in the redirect URL Spotify sends when using Apple/Google login
Cookie/session state mismatch

I’ve verified that:

The code param is being received from Spotify
The app works fine when logging in the standard way
I’m not re-reading the response body more than once
Any ideas what could cause this issue when using Spotify login via Apple or Google specifically?
Would really appreciate any insight or suggestions.  Ive attached images of the callback route.

Thanks in advance!

 

 

 

Screenshot 2025-05-28 at 10.13.15 AM.png
Screenshot 2025-05-28 at 10.13.25 AM.png
Screenshot 2025-05-28 at 10.13.30 AM.png
Reply
0 Replies

Suggested posts

Let's introduce ourselves!

Hey there you,   Yeah, you! 😁   Welcome - we're glad you joined the Spotify Community!   While you here, let's have a fun game and get…

ModeratorStaff / Moderator/ 4 years ago  in Social & Random