Add Spotify integration with improved token management and user interface
- Implemented Spotify OAuth handling in spotify_client_manager.py to ensure valid access tokens for users. - Created helper functions in spotify_helper.py for refreshing tokens and retrieving user information. - Developed manage_spotify.html template for connecting and managing Spotify accounts, displaying connection status and token information. - Added logging for token management processes to enhance debugging and monitoring. - Introduced a debug client for Spotify interactions to facilitate easier testing and development.
This commit is contained in:
+10
-6
@@ -13,25 +13,29 @@ logger = logging.getLogger(__name__)
|
||||
# Add the parent directory to the path so we can import modules
|
||||
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
|
||||
|
||||
def run_oauth_migration():
|
||||
"""Run the migration to add OAuth provider columns"""
|
||||
# Ensure the project root is also in the path for musicround imports
|
||||
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) # Assuming run_migration.py is in project root
|
||||
if project_root not in sys.path:
|
||||
sys.path.insert(0, project_root)
|
||||
|
||||
def run_spotify_oauth_migration():
|
||||
"""Run the migration to add Spotify OAuth columns"""
|
||||
try:
|
||||
# Create a minimal Flask app with database connection
|
||||
from musicround import db, create_app
|
||||
app = create_app()
|
||||
|
||||
with app.app_context():
|
||||
logger.info("Starting OAuth providers migration...")
|
||||
logger.info("Starting Spotify OAuth columns migration...")
|
||||
|
||||
# Import and run the migration script
|
||||
from migrations.add_oauth_providers import run_migration
|
||||
from migrations.add_spotify_oauth_columns import run_migration
|
||||
success = run_migration()
|
||||
|
||||
if success:
|
||||
logger.info("Migration completed successfully!")
|
||||
return True
|
||||
else:
|
||||
# This is the key change: don't treat "no changes" as a failure
|
||||
logger.info("Migration reported no changes needed - continuing anyway")
|
||||
return True # Return True even when no changes were made
|
||||
|
||||
@@ -40,5 +44,5 @@ def run_oauth_migration():
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
success = run_oauth_migration()
|
||||
success = run_spotify_oauth_migration()
|
||||
sys.exit(0 if success else 1) # Exit with 0 (success) or 1 (error)
|
||||
Reference in New Issue
Block a user