diff --git a/backend/endpoints/spotify_api.py b/backend/endpoints/spotify_api.py index e7d32dd..da44e7b 100644 --- a/backend/endpoints/spotify_api.py +++ b/backend/endpoints/spotify_api.py @@ -4,7 +4,7 @@ import requests import os from auth.session import SessionData, current_session -api = APIRouter(prefix="/music") +music_router = APIRouter(prefix="/music") SPOTIFY_CLIENT_ID = os.getenv("SPOTIFY_CLIENT_ID") SPOTIFY_CLIENT_SECRET = os.getenv("SPOTIFY_CLIENT_SECRET") @@ -14,7 +14,7 @@ SPOTIFY_TOKEN_URL = "https://accounts.spotify.com/api/token" SPOTIFY_PLAY_URL = "https://api.spotify.com/v1/me/player/play" # Step 1: Redirect user to Spotify login -@api.get("/login") +@music_router.post("/login") def login(): scope = "user-modify-playback-state user-read-playback-state" url = ( @@ -26,7 +26,7 @@ def login(): return RedirectResponse(url) # Step 2: Callback to get access token -@api.get("/callback") +@music_router.post("/callback") def callback(code: str): payload = { "grant_type": "authorization_code", @@ -47,3 +47,6 @@ def callback(code: str): return {} +@music_router.get("/search") +def search(query: str): + pass diff --git a/backend/main.py b/backend/main.py index b44d4ae..c43b17b 100644 --- a/backend/main.py +++ b/backend/main.py @@ -4,6 +4,7 @@ from fastapi.middleware.cors import CORSMiddleware from endpoints.geo_access import geo_access_router from routes import router +from endpoints.spotify_api import music_router load_dotenv() @@ -21,6 +22,7 @@ app.add_middleware( # Includi le route app.include_router(router) app.include_router(geo_access_router) +app.include_router(music_router) @app.post("/auth")