Invalid Client ID when trying to Authorize API

Invalid Client ID when trying to Authorize API

I am trying to take the billboard top 100 songs from a given date and generate a spotify playlist. I have replaced my client ID and secret with random values for privacy. When I execute the code below, I am expecting a browser to pop up that asks me to agree to spotify conditions. I have edited the settings in the developer tab in spotify to the redirect URI below and have obtained the correct client ID and secret from my account. 


Help greatly appreciated. 

import requests
from bs4 import BeautifulSoup

import spotipy
from spotipy.oauth2 import SpotifyOAuth

CLIENT_ID = "abcde"

date = input("What year do you want to travel to? Type the date in this format YYYY-MM-DD")

URL = f"{date}/"
response = requests.get(URL)
webpage = response.text
soup = BeautifulSoup(webpage, "html.parser")

title ="li ul li h3")

song_list = [title[song].getText().strip() for song in range(0,100)]


sp = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id="CLIENT_ID",
show_dialog = True,
cache_path = "token.txt")

user_id = sp.current_user()["id"]





2 Replies

You have 


in your code, but you need to remove the "quotes" around those variables. Else they are the strings "CLIENT_ID" and "CLIENT_SECRET". 

You are literally a godsend. I have been wondering what the heck is wrong with my code for like 5 days now. Thank you kind stranger!! 

Suggested posts