My Jammming project


here’s my Jammming project:

Repository: GitHub - qapush/codecademy-jammming

Any feedback is appreciated :raised_hands:

Hey just a question as I am getting overwhelmed with this project and using yours as sort of “coding backwards” and I am super stuck on the Spotify Authorization. When I look in their documentation it seems super complicated and yours is a) very smooth and to the point and b) very different from someone else who has submitted theirs.

Where did you get the authorization and getToken code from? Did you make it yourself? Any advice for resources?

1 Like

Hey @kiko_noia

yeah this project is really intimidating at first but we’re here to help each other!

I’ve found the idea of how to get the token by both looking here at forum and at the docs. And it schematically looks like this:

  • at the very beginning app doesn’t have the token value so the first request to Spotify API is actually requesting the token
  • to request the token you redirect user to the authorisation page but here you should use some parameters in the URL like ID of your app and URL to redirect user back (basically the same URL as your app)
  • if everything is fine after redirect back to app the URL will include the access token in the hash fragment (after the # sign)
  • at this point you can retrieve the token form that portion of the URL and assign that value to your token variable in the code

So my getToken function does this:

  • if the token variable has a value assigned → return it
  • else if there is a hash in the URL and it includes token value → assign it to the global token variable (to reuse in previous if while making another requests), clear the URL from hash and return the token value
  • else redirect user to the authorisation page and redirect back (so basically when we return to getToken function again we will be on previous step - retrieving token value from URL)

Hope this helps somehow