21 lines
626 B
Python
21 lines
626 B
Python
from spotipy.oauth2 import SpotifyOAuth
|
|
from spotipy import Spotify
|
|
from spotify_shortcuts.config import Config
|
|
|
|
CALLBACK_URI = "http://127.0.0.1:45632/callback"
|
|
|
|
|
|
def authenticated_session(cfg: Config, scopes: list[str]) -> Spotify:
|
|
assert cfg.client_id, "Spotify client ID is required"
|
|
assert cfg.client_secret, "Spotify client secret is required"
|
|
|
|
return Spotify(
|
|
auth_manager=SpotifyOAuth(
|
|
client_id=cfg.client_id,
|
|
client_secret=cfg.client_secret,
|
|
redirect_uri=CALLBACK_URI,
|
|
scope=" ".join(scopes),
|
|
cache_path=cfg.cache_file,
|
|
)
|
|
)
|