Announcements

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

Invalid Client Error w/Spotify Web API

Invalid Client Error w/Spotify Web API

Plan

Free/Premium

Country

United States

 

My Question or Issue

 

My team and I are getting a "Invalid Client" / WebapiAuthenticationError: An authentication error occurred while communicating with Spotify's Web API error

We can confirm that we have quadruple checked the client id and client secret in our being the exact same from our dev dashboard, we can confirm that we recreated a client secret as well. 

Our use case is simple, we created a cloud function via firebase that makes endpoint calls to the Spotify Web Api every 30 minutes to extract our apps user most recently played tracks from spotify. Here's a small example snippet of the begging of our code structure to reference my use case above. 

const functions = require("firebase-functions");
const admin = require("firebase-admin");
const SpotifyWebApi = require('spotify-web-api-node');

admin.initializeApp();

exports.getRecentSongs = functions.pubsub.schedule('every 30 minutes').onRun(async (context) => {
// Initialize Spotify Web API
const spotifyApi = new SpotifyWebApi({
clientId: 'myclientid',
clientSecret: 'myclientsecret'
});

(*
Screenshot 2023-06-29 at 7.42.47 PM.pngsee e rror code screenshot attached)
Reply
1 Reply

You should use code for the Authorization code flow with the user-read-recently-played scope.

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Suggested posts