I'm trying to make a dashboard that controls Spotify playback with Flask. I've been trying to use Spotipy to achieve this, but I am confused on how to authenticate a user token through a Flask server.
This is my code currently:
from flask import Flask, jsonify, request, render_template
import os
import spotipy
from spotipy.oauth2 import SpotifyOAuth
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id="id",
client_secret="secret",
redirect_uri="http://localhost:5000",
scope="user-read-playback-state,user-modify-playback-state,user-read-currently-playing,app-remote-control"))
app = Flask(__name__)
@app.route("/")
def index():
return render_template("index.html")
@app.route('/pause')
def pause():
sp.pause_playback()
if __name__ == "__main__":
app.run(debug=True)