Skip to content

ixd-system-design/Spotify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spotify Basic

This demo shows how we can connect to the Spotify API using the Client Credentials OAuth flow.

Backend

The backend server.js uses a simple Express app to publish a /token endpoint. It exposes a fresh Spotify Token on demand. It does this by forwarding the token request to Spotify. It assumes that we will store our spotify credentials as server environment variables.

Frontend

The frontend lives in the /public folder. It includes scripts for fetching and caching a token via the backend /token endpoint. It hits the Spotify latest releases endpoint directly, passing the Token along in the Headers.

Environment Variables

Be sure to add server environment variables for your Spotify CLIENT_ID and CLIENT_SECRET so that a fresh token can be fetched when needed. You can find these credentials in your Spotify Developer dashboard. For example, you might paste these as key value pairs at the end of your .env file so that NodeJS can find them. It might look something like this:

CLIENT_ID=abc123***
CLIENT_SECRET=abc123***

Vercel

This project has been setup for compatibility with Vercel. Did you know that you can host an Express app on Vercel as a serverless function? In this way your static assets are hosted efficiently, but you can also deploy a basic backend as well. Read more about how Express apps are hosted on Vercel.

About

Spotify Web API basic auth demo with token refresh to show latest releases

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors