This repository was created as a toy learning project for technologies as a React, Apollo GraphQL & ChartJS. Project also uses Spotify API for server in own defined schema.
- installed
yarn
- installed
node
with minimal version16.X.X
- https://api.spotify.com/v1/me for app route
/
- https://api.spotify.com/v1/browse/featured-playlists for app route
/playlists
- https://api.spotify.com/v1/search for app route
/search-track
- https://api.spotify.com/v1/me/following for app route
/followed-genres
- https://accounts.spotify.com/ for Login to Spotify and return
access_token
Connecting to data always needs to be authorized by Oauth token. Token has different roles for different data. In this repository were used 2 types of Bearer
tokens, which you need to generate.
Warning Token expires after some time.
For standard endpoints calling, it possible to generate token here:
- Copy token into
.env
file in /server/root
- This token covers app parts: /
, /playlists
and /search-track
For /followed-genres
is needed to generate token here https://developer.spotify.com/console/get-following/?type=artist&after=&limit= and check required scope user-follow-read
.
- is needed to have generated
CLIENT_ID
andCLIENT_SECRET
from https://developer.spotify.com/.
- go to https://developer.spotify.com/dashboard/applications
- create app with button
CREATE AN APP
and fill in mandatory fields - copy values of generated
CLIENT_ID
andCLIENT_SECRET
- in edit settings add
Redirect URIs
ashttp://localhost:3000/
- copy file
.env.copy
from/server/root
and rename it to.env
- copy values of
CLIENT_ID
andCLIENT_SECRET
into.env
file
- copy file
.env.copy
from/client/root
and rename it to.env
- copy values of
REACT_APP_CLIENT_ID
into.env
file (value is the same asCLIENT_ID
)
Note: On the client side with React, environment variables need to start with prefix REACT_APP_
.
Note2: Is needed to restart application after adding variable in .env
file.
Warning: Do not store any secrets (such as private API keys) in your React app!
- called if API returns 401 from the server and user is not authenticated with non expired
access_token
- after submit button and login to
spotify.com
as standard user, logged user has generated and savedaccess_token
into local storage with keyspotifyToken
- if this token expired, user needs to click on
Login to
button again and token is automatically generated again
- returns info about logged user
- returns users playlists, it is possible to sort ASC/DESC by playlists name
- every playlist card has link button, with which is possible to open playlist on
Spotify
- returns searched tracks
- is possible to listen 30s song/track preview inside the page
- returns users followed genres
- data shows into doughnut chart graph
- returns, if there is some error from API communication
This repository uses eslint
, which is also running in pipeline after push code into branch or merge into main.