Search code examples
c#winformsspotify

C# Windows Forms Spotify API User Authorization


I'm trying to authorize a spotify user in my windows forms application. I am able to make a GET call to the web API, and I get a response back that is HTML. When loaded into the browser, this HTML is a login page, but my question is two parts.

1) What would be the best way to display this login page. Obviously if I could launch the browser and have it return the authorization code somehow, that would be best, which brings me to my second question.

2) How would I get the authorization code from the browser when I launch the login screen? I can't see a way that my forms application would be able to receive any information after the login screen is launched. Sorry if this seems obvious.


Solution

  • I figured it out, the URL I was using was not meant to be requested from, but to have the user navigate to in their browser. I basically just put the link in my application as a button and it would launch in chrome. Once the user logs in, I used http://httpbin.org/get to display the authentication code and just copied the code into my app as a temporary fix. Obviously this is not ready for release, and I am still working out how to get the code from the redirect url to my application, but it's a step in the right direction!