aggiunta router
This commit is contained in:
parent
4e74bbb443
commit
a7f82eebad
2 changed files with 8 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue