Announcements

Help Wizard

Step 1

NEXT STEP

invalid client

invalid client

hi im trying to run some simple code to test out spotifys api

import spotipy
from spotipy.oauth2 import SpotifyClientCredentials

# Set up Spotipy client credentials
client_id = 'YOUR_CLIENT_ID'
client_secret = 'YOUR_CLIENT_SECRET'
client_credentials_manager = SpotifyClientCredentials(client_id=client_id, client_secret=client_secret)
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)

# Retrieve a list of all devices connected to the user's Spotify account
devices = sp.devices()

# Print out the device IDs and names
for device in devices['devices']:
print(f"Device ID: {device['id']}, Device Name: {device['name']}")


I replaced YOUR_CLIENT_ID, and YOUR_CLIENT_SECRET with the id and secret provided in my app in spotify for developers but

i'm recieving an "invalid_client" error suggesting that the client ID and/or client secret provided in the code are not valid.
I have checked many times and they are exactly the same.

please help me i dont know what is wrong

Reply
1 Reply

You can't use sp.devices() with Client Credentials.

You should use the code With user authentication.

The scope you should use is user-read-playback-state.

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

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