Coder Social home page Coder Social logo

livrbecca / spotifyfestivalposter Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 216 KB

React Application that allows the users to see their Spotify data relating to who their top artists are as festival poster

Home Page: https://create-your-lineup.netlify.app

HTML 7.82% CSS 72.32% JavaScript 19.86%
react spotify-api authentication implicit-flow react-router-dom react-components react-hooks

spotifyfestivalposter's Introduction

Create Your Own Festival Poster

Please note, you must have a Spotify account to use this app.

Users log into the app via their Spotify account (implicit grant authorization flow) and are able to view their personalised data relating to who their top artists are displayed as a festival poster line-up.

Deployment

lineup

Stack

How The Authorization Works:

For more information: visit the Spotify guides for Auth: https://developer.spotify.com/documentation/general/guides/authorization-guide/

  • This application uses Spotify's Implicit Grant Authorzation flow, which grants temporary user authorization. -To begin, the user must log into Spotify, heading to https://accounts.spotify.com/authorize with additional parameters in the query string.
  • Paramaters I used:
    • client id
    • re-direct url
    • necessary scopes
  • example: https://accounts.spotify.com/authorize/clientid/redirecturl/scopes - there are more optional params that can be includes for additional features -This was all put inside a button onClick function to direct the user there when clicking 'log in to spotify'

-Once the user is logged in, they are directed towards my variable 're-direct url', for this project mine is set to the Poster component, and the same time, the users access token is also passed to the application (if they logged in successfully and granted access)

  • once redirected, final URL will contain a hash fragment with the following data encoded as a query string
    • access token necessary
    • token type optional, one word that can be written out yourself
    • expires in optiona, but not necessary

-The access token is needed to access the users top artists during the GET request, so I created a function getReturnedParamsFromSpotifyAuth that would extract the token from the URL bu using the reduce method and putting them into an object

  • Next I defined a useEffect that would run the above function on page load to get the users access token and save it in localStorage ready for later use.
  • using the React hook, useState I defined:
  • const [token, setToken] = useState("") and inside the above useEffect I had conditional logic to say, if there is an access token in local storage, do setToken(token-that-was-in-local-storage)

Now that you have the users access token, you are able to do GET requests on their top artists and and have successfully achieved authorization!

spotifyfestivalposter's People

Contributors

livrbecca avatar

Watchers

 avatar

spotifyfestivalposter's Issues

meqia-queries

Need to add final media queries for 'mobile first' design

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.