Getting redirect_uri error when implementing Spotify Web API authentication

I’m working on integrating Spotify’s Web API into my Node.js application and keep running into an authentication issue. When I attempt to redirect users to Spotify’s authorization page, I receive an error saying the redirect URI is invalid.

I’ve double-checked my application settings in the Spotify dashboard and confirmed the callback URL matches what I have in my code. Here’s the relevant part of my implementation:

const express = require('express');
const axios = require('axios');
const qs = require('querystring');
const cookieSession = require('cookie-session');

const CLIENT_ID = myClientId;
const CLIENT_SECRET = myClientSecret; 
const CALLBACK_URL = "http://localhost:8888/callback";

I’ve been stuck on this for quite a while now and can’t figure out what’s causing the mismatch. Has anyone encountered this issue before?

i know this struggle, check if ur app is in dev mode on spotify dashboard, it restricts ur redirect uris more than production. also, localhost vs 127.0.0.1 can throw off things. been there!

Oh man, this redirect URI thing killed me for hours when I started using Spotify’s API. The issue isn’t always clear from looking at your code. Spotify’s super picky about exact URL matching - even trailing slashes matter. If your dashboard has a trailing slash but your code doesn’t (or the other way around), you’re screwed. Also double-check you didn’t accidentally add query parameters to the registered URI. Keep it to just the base callback URL. Case sensitivity can bite you too, though it’s rare with localhost. Still stuck? Try switching to a different port and update both your code and dashboard. Sometimes clearing your browser cache works since auth flows get cached in weird ways.

Been there with Spotify auth - the redirect URI matching is absolutely brutal. There’s a way cleaner approach though.

Stop wrestling with authentication edge cases and debugging callback URLs for hours. You can automate the entire Spotify API workflow instead. I’ve built integrations where auth flow, token management, and API calls all run seamlessly without babysitting redirect URIs.

Set up the authentication dance once, handle token refreshing automatically, and never deal with localhost callback mismatches again. You can easily switch between dev and production without constantly updating dashboard settings.

Too many developers waste days on OAuth callback issues when they could automate everything in minutes. Set it up right once and focus on building actual app features instead of fighting auth flows.

Check out Latenode for handling this kind of API integration smoothly: https://latenode.com