Announcements

Spotipy Web Application, how to retrieve OAuth code?

Reply
Highlighted

Spotipy Web Application, how to retrieve OAuth code?

Visitor

Hello all,

I am branching out into trying to setup a Web Application for the first time, and I'm trying to make something with Spotify since I use it very often. I have a URL setup with my registered app on Heroku and I've got some barebones Python written using the Spotipy library.

 

I have created several Twitter apps using OAuth before, so I have a rough idea of how it works conceptually. I redirect the user to a permissions page, upon which accepting they generate me a code which I can use to gain access to their account. Since my Twitter apps run off a Raspberry Pi, I was able to save these codes locally to pass between my script. But I have no idea how to retrieve them off a web application. 

 

For example, I have configured this initial GET request ( https://accounts.spotify.com/authorize?client_id=559598eb217440abb4fcd7629a363a53&response_type=code...user-read-email%20user-top-read ) which seems to work great! I can click through to authorize my app, and I'm redirected back to my Heroku site, I can see the auth code embedded in the URL too! My question is, how do I retrieve this token out of the URL to continue the authentication process?

 

If I pipe the GET request to a variable, and then expand the contents of the response, it's just HTML (presumably of the permissions page), there's no JSON in there at all. 

This is as far as I've gotten, and it really feels like I'm stumbling at the very first hurdle. I appreciate this is probably a broader "teach me about web application framework" question than Spotify specifically, but I'd really, really appreciate any advice or guidance at all!

 

EDIT: Seems as though the forum doesn't like long URLs, here's a shortened version : https://tinyurl.com/y5l3nwum

1 Reply
Highlighted

Re: Spotipy Web Application, how to retrieve OAuth code?

Regular
SUGGESTED POSTS