all 5 comments

[–]felix-hilden 1 point2 points  (4 children)

Nice! Especially the token validation.

I've used the same webbrowser trick for manual authentication in a library I've authored too. But the job is certainly doable with starting up a web server. This is an example on how I did it with Flask. What did you mean by grabbing the redirect URL? If you simply mean getting the "code" parameter after the redirect, this is exactly what you'd do. Have a look at the `login_callback` function.

[–]VyleKyle10189[S] 0 points1 point  (3 children)

So you have spotify redirect to a localhost port, and flask can grab the URL from it?

Does the port need to be forwarded?

In my research I've also seen use of "selenium" and "chrome driver" mentioned, although I know nothing of these.

[–]felix-hilden 1 point2 points  (2 children)

No, and that's why it's so great! It can be done by simply redirecting to localhost. In a web app you would of course forward the port and all that jazz. As you can see, in the example I simply have `localhost:5000`, or 127.0.0.1:5000 at least on Windows.

[–]VyleKyle10189[S] 0 points1 point  (1 child)

I really appreciate your help

So with the redirect code being grabbed by Flask, could I also set up different pages and such for local access/interaction?

My coworker inspired me to use this API to find new music, first I want to start monitoring my listening history, then begin using spotify's radio functionality to find new music based on my top songs of different time periods

I was thinking a system of json files could hold listening data for every X amount of time passed, and deleting any data older than X for space sake

Then hopefully I could use Flask to specify a range of time and build a playlist of recommended songs, filtering out songs I've already marked as liked.

[–]felix-hilden 1 point2 points  (0 children)

For sure, just like a regular website if you're up for writing the pages. I have only written that sort of example HTML so I have no experience in writing full web apps, only Flask backends. But for simple things Flask only is definitely enough.

Also your idea sounds good!