Redirect uri Authentication with Spotipy

Hello!
I am currently building out a project on Streamlit with the library spotipy. In order for users to fully access the site and use features I would like to build, they need to authenticate it. This gives them a redirect uri which gives access to other parts of the script to be utilized.

I can run this locally and when I click a button, the redirect uri happens, the site is happy and everything runs well. However when I push to the web and I click the button, it no longer redirects and gets stuck waiting for the code from the redirect uri.

Has anyone else experienced this or have a work around?

I am currently stuck on this step as well! I’m able to read the client credentials by passing them as secrets, but the redirect URI is hanging every time I reboot.

Let me know if you find a solution, and I’ll do the same.

Figured it out! I went down quite the rabbit hole trying to use selenium to open up an auth window in the app, hacking the Cloud containers to install browsers with os.system(), and finally a headless browser with user/pw input from the app.

In the end, it’s as simple as displaying a hyperlink for login using markdown and html, redirecting the auth page back to your app url, and using st.experimental_get_query_params() to obtain the code from the response url.

Additionally, during this process I learned that the Spotify Developer platform only allows 25 named users in its first tier; you need the email associated with every users’ account. After that, you must request a quota extension, which they explain is not for “hobby projects”. :man_shrugging:

Anyway, hope that helps! Feel free to use anything in my first working version.

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.