fix: use paste-URL auth flow, match redirect URI to spotify app (port 8888)
This commit is contained in:
BIN
__pycache__/musictail_mcp.cpython-311.pyc
Normal file
BIN
__pycache__/musictail_mcp.cpython-311.pyc
Normal file
Binary file not shown.
@@ -32,10 +32,10 @@ def get_spotify_client() -> spotipy.Spotify:
|
||||
auth_manager = SpotifyOAuth(
|
||||
client_id=os.environ.get("SPOTIFY_CLIENT_ID"),
|
||||
client_secret=os.environ.get("SPOTIFY_CLIENT_SECRET"),
|
||||
redirect_uri="http://127.0.0.1:8889/callback",
|
||||
redirect_uri="http://127.0.0.1:8888/callback",
|
||||
scope=SCOPES,
|
||||
cache_path=cache_path,
|
||||
open_browser=True
|
||||
open_browser=False
|
||||
)
|
||||
return spotipy.Spotify(auth_manager=auth_manager)
|
||||
|
||||
@@ -301,11 +301,32 @@ if __name__ == "__main__":
|
||||
import sys
|
||||
if "--auth" in sys.argv:
|
||||
print("🎵 MusicTail — First-time authorization")
|
||||
print("A browser window will open for Spotify login...")
|
||||
sp = get_spotify_client()
|
||||
user = sp.current_user()
|
||||
print(f"✅ Authorized as: {user['display_name']} ({user['id']})")
|
||||
print(f"Token cached at: ~/.musictail_cache")
|
||||
print("MusicTail is ready! 🦊")
|
||||
print()
|
||||
cache_path = os.path.expanduser("~/.musictail_cache")
|
||||
auth_manager = SpotifyOAuth(
|
||||
client_id=os.environ.get("SPOTIFY_CLIENT_ID"),
|
||||
client_secret=os.environ.get("SPOTIFY_CLIENT_SECRET"),
|
||||
redirect_uri="http://127.0.0.1:8888/callback",
|
||||
scope=SCOPES,
|
||||
cache_path=cache_path,
|
||||
open_browser=False
|
||||
)
|
||||
# Get the auth URL
|
||||
auth_url = auth_manager.get_authorize_url()
|
||||
print(f"Open this URL in your browser:\n{auth_url}\n")
|
||||
print("After authorizing, you'll be redirected to a URL.")
|
||||
print("Paste the FULL redirect URL here (it will start with http://127.0.0.1:8888/callback?code=...):")
|
||||
response_url = input("> ").strip()
|
||||
code = auth_manager.parse_response_code(response_url)
|
||||
token_info = auth_manager.get_access_token(code)
|
||||
|
||||
if token_info:
|
||||
sp = spotipy.Spotify(auth_manager=auth_manager)
|
||||
user = sp.current_user()
|
||||
print(f"\n✅ Authorized as: {user['display_name']} ({user['id']})")
|
||||
print(f"Token cached at: {cache_path}")
|
||||
print("MusicTail is ready! 🦊")
|
||||
else:
|
||||
print("❌ Authorization failed. Check your credentials.")
|
||||
else:
|
||||
mcp.run()
|
||||
Reference in New Issue
Block a user