Announcements

Help Wizard

Step 1

NEXT STEP

[Personal Project] What kind of authorization to use?

[Personal Project] What kind of authorization to use?

Hey, I have been working on a voice-command assistant (here's the github: https://github.com/JonasRSV/friday-voice-assistant) and I'd like to enable starting Spotify songs with it.

 

When reading up on authentication flows for the web-api it seems as all options require me to redirect a user to some webpage to login, also the authorization flows seem to assume that my app has some kind of UI.

 

What I was hoping for was some way to download a token or key that lets me call the web-api. But I can't find anything on this.

 

My question is, how do I authorize an application that has no UI? How do I give my assistant access to my own player?

 

E.g working with philips-hue I can 'create' a user and use my 'user' token to control my lights, is something similar possible with the spotify API?

 

I can see in my dashboard that I have a client-id and client-secret, but API-endpoints require an access token which seems to require me having a UI to get?

Reply
1 Reply

I solved this by setting up a simple temporary tcp listener on my computer at localhost:9000 (or any free port) in my script and adding this as redirect URL in my application profile in Spotify.

 

Then I grabbed the incoming data and parsed the auth code from that using regex.

 

A http listerner would be even simpler but requires elevation in my specific case (using .NET methods) which I wanted to avoid.

 

I did all this in PowerShell, but it's definitely possible in python, setting up a http listener is quite simple in python so that's where I'd look. It only needs to live while doing the request and getting the auth code back.

Suggested posts