Spotify Widget for macOS

Product Engineer

Impact

  • Implemented full OAuth 2.0 Authorization Code Flow with Spotify Web API including automatic token refresh
  • Built Flask web server handling login redirect, callback token exchange, and real-time currently-playing retrieval
  • Designed stateless two-file architecture separating OAuth handshake from API consumption logic
  • Enabled cross-platform compatibility via PyAutoGUI with macOS-specific and Windows-specific hotkey support

Skills

PythonFlaskRequestsSpotify Web APIOAuth 2.0
Spotify Widget for macOS

Project Abstract & Details

A learning-focused macOS widget that integrates with the Spotify Web API via OAuth 2.0 to display and control currently playing music. Built as a utility project to explore OAuth Authorization Code Flow, automatic token refresh mechanisms, and REST API integration patterns. The widget retrieves real-time playback state (track title, artist, album art, progress), enables play/pause/skip controls, and displays recently played tracks. Note: This is a learning/utility project exploring Spotify API integration patterns — not a production-grade macOS widget.

Key Features

OAuth 2.0 Flow

Authorization Code Flow with PKCE — handles login redirect, callback token exchange, and automatic token refresh every 60 minutes

Spotify Web API

REST API integration for currently-playing, playback control (play/pause/skip), recently played, and user profile endpoints

Desktop Widget

PyAutoGUI-powered overlay widget with macOS and Windows hotkey support for seamless media control

Flask Auth Server

Lightweight Flask server handling the OAuth callback, token storage, and API proxy requests

Stateless Architecture

Two-file design cleanly separates OAuth handshake logic from Spotify API consumption — saves tokens as JSON

Token Refresh Pipeline

Automatic 401 detection triggers token refresh using refresh_token — seamless uninterrupted playback tracking

Architecture

Stateless two-file architecture: (1) spotify_oauth.py handles the OAuth 2.0 Authorization Code Flow — redirects user to Spotify login, exchanges authorization code for access/refresh tokens, and automatically refreshes expired tokens. (2) spotify_widget.py consumes the Spotify Web API using stored tokens — polls /v1/me/player/currently-playing every 5 seconds, displays track info in a PyAutoGUI overlay, and supports media control via keyboard shortcuts. No database required — tokens stored as JSON in user config directory.

Architecture diagram placeholder

Outcomes & Metrics

OAuth 2.0
Auth Flow
60min
Token Refresh
5s
Poll Interval
2
Files Total

© Developer Portfolio by KV