asf
This commit is contained in:
parent
7147a7133b
commit
327e0f95d1
3 changed files with 16 additions and 10 deletions
2
.cache
2
.cache
|
@ -1 +1 @@
|
|||
{"access_token": "BQBCjzsh0Tm5K8GnkwtrmvavDRuUoGAOCl8yfKyjt6oeatCjmLY8fqMk5Wx66rZHNqf-YQiMBofXHershMVVHxea-Exh2mwMwp9z5kFf56LsWqwIcsUZbOxzEJjm-JjK37fKfR9KpM5NLeZ9bcGuWKnfpKjWj1qJfQmhei8eKs9n-QjG-wt1dTLB1ujRk2ROwah4XkxMkewXNaSVhW_y5aDL3lk", "token_type": "Bearer", "expires_in": 3600, "refresh_token": "AQAKTdSkH3SoqppmeSMvp52V_25lCRFgZPTv4wTXcJLqV7uU1-SJWK6mpW0n2NivNSoWNQxRd3Qteuxp3GXW6_BSa4bh8fYcKH63G1TWEjRyvw2sE_I5PqxCLUY_Pvcf0k0", "scope": "user-modify-playback-state user-read-playback-state", "expires_at": 1737231157}
|
||||
{"access_token": "BQDWRLvhDrrBniuV9APL5Di0UGlrhl44TKLkY3Sa0mmnsL5gdmm9O_23jXvA5lknad4pKL84ToegWQl97fSQP_tCgRccsJopfiRw8Rp7orKUfygCZjAal2Nc2AdlFO0VMDT0nBDON6E1ffBYUyiBqEE6yZYjq6bVC9kaTt8nAzn2d1Ts-dqbvCHKhSEhMWnt8ds3TmZIBD-UGOEfeihAn6PzR7g", "token_type": "Bearer", "expires_in": 3600, "refresh_token": "AQAqsBVwK834WIPG82EZXiGi23iuTHFMAyHSCTk2_qcrMbURurGOlF9KE07JwblqfviRMiymDOEYgjvIh-A-Me4fkuC1B-4AWaM5eY9YSVlV1u5i-Pn9GE3Hw8PNc7JENO0", "scope": "user-modify-playback-state user-read-playback-state", "expires_at": 1737283652}
|
Binary file not shown.
24
app.py
24
app.py
|
@ -1,4 +1,4 @@
|
|||
from flask import Flask, render_template, request, jsonify
|
||||
from flask import Flask, render_template, request, jsonify, url_for
|
||||
from spotipy import Spotify
|
||||
from spotipy.oauth2 import SpotifyOAuth
|
||||
from dotenv import load_dotenv
|
||||
|
@ -13,17 +13,23 @@ app = Flask(__name__)
|
|||
# Spotify API credentials from environment variables
|
||||
CLIENT_ID = os.getenv("CLIENT_ID")
|
||||
CLIENT_SECRET = os.getenv("CLIENT_SECRET")
|
||||
REDIRECT_URI = "http://0.0.0.0/callback"
|
||||
SCOPE = "user-modify-playback-state user-read-playback-state"
|
||||
|
||||
# Spotipy client
|
||||
sp = Spotify(auth_manager=SpotifyOAuth(
|
||||
client_id=CLIENT_ID,
|
||||
client_secret=CLIENT_SECRET,
|
||||
redirect_uri=REDIRECT_URI,
|
||||
scope=SCOPE,
|
||||
open_browser=False # Disable interactive input
|
||||
))
|
||||
sp = None # Initialize the Spotify client later after setting the dynamic redirect URI
|
||||
|
||||
@app.before_request
|
||||
def setup_spotify_client():
|
||||
"""Setup the Spotify client with a dynamic redirect URI."""
|
||||
global sp
|
||||
REDIRECT_URI = f"{request.host_url}callback".rstrip("/")
|
||||
sp = Spotify(auth_manager=SpotifyOAuth(
|
||||
client_id=CLIENT_ID,
|
||||
client_secret=CLIENT_SECRET,
|
||||
redirect_uri=REDIRECT_URI,
|
||||
scope=SCOPE,
|
||||
))
|
||||
|
||||
|
||||
# Home route
|
||||
@app.route("/")
|
||||
|
|
Loading…
Add table
Reference in a new issue