CSI-280 / MusicGames

0 stars 0 forks source link

Spotify Cleint #25

Closed A-Waters closed 4 years ago

A-Waters commented 4 years ago

Alrighty, here's how this bad boy works.

check your email

more on this^^ later

Basically while working on this I realized Spotify doesn't want us doing almost exactly what we are doing. On this note, some things needed to change (more on that later). Here is how it is currently working.

  1. users clicks login
  2. we open a new tab that sends data to Spotify containing our client ID
  3. user logs into Spotify
  4. the tab gets redirected to a new page on our website (public/callback.html) with more data 4.5 note this tab is not a react based page because of complications
  5. the tab tells our "main" tab that we need our client id for the next step
  6. our main tab sends the ID over
  7. we load our "secret_token" into the second tab
  8. our second tab will then send data back to Spotify using our "secret_token"
  9. Spotify sends back an access token for the user (and a refresh token)
  10. our second tab will then send that token to the Spotify client to be used in the request to the api
  11. close our second tab 12.+ use this token to request data through the Spotify user

Spotify doesn't really want us sharing an account for accessing their API and this does it quite nicely (I thinks it's against their TOS?). What this means is that the login process has been changed a little bit, so now the users need a Spotify account (i don't think it needs to be premium), and that we only need to save the users ID (with associated TBD data e.g. how many coins they have) in the DB meaning we don't have to now deal with passwords and usernames.

I Have implemented a few of the APIs functionality to the client (what I think we are going to need). and they are pretty easy to read/understand all located under /frontend/gui/src/spotify_client.js.

Basically you can just import the client via

import SpotifyClient from 'pathtofile/SpotifyClient.js'

and then call the functions on it

and you have all been emailed a file (shortly after I make this request) which should be placed in /frontend/gui/public/. The reason I can't upload this file to the repository is that if someone has the data inside of it they can control our program. I added a .gitignore to help avoid this problem.

LMK if you have any questions or concerns.

lenora4321 commented 4 years ago

What if we don't have a spotify account and don't want to get one? In other words, I may not be the best person to be testing this right now

A-Waters commented 4 years ago

I don't think then we are allowed to make a request to Spotify API without breaking their TOS, aka a single account, we distribute. I Think for terms of testing rn we can just use the account that was made in issue #3 @lenora4321. Where we run into problems is when/if the server goes live.

jbuzzell commented 4 years ago

i see no problem with setting up the spotify client like this. whatever works works. what exactly about this commit links it to creating user data in django? i see no migrations or other updates to the db in the commits

A-Waters commented 4 years ago

@jbuzzell I have made no changes currently to the backend side of things, It just when we start working on it, we have to keep in mind.

A-Waters commented 4 years ago

@jbuzzell we simply just have to store different information about how we identify users the rest stays the same.

jbuzzell commented 4 years ago

makes sense, thanks for the clarification

lenora4321 commented 4 years ago

A marvelous bit of code