I’ve just been working on something similar, to be honest I’m no expert with WPF so I’ve put together a solution based on the following useful resources.
First you do need a very simple web server to listen for the response from the initial oAuth call, I used this as my starting point:
Second I set up a very simple Window containing one WebBrowser Control. The only bit of code is to set this to navigate to the initial Authorization url, something like this:
Third take a read (I’m sure you already have) of this article particularly read about the Authorization Code Flow:
Last bit, take a look at the code I posted here:
Make sure you fix the PUT to POST.
Then you’ve got all the pieces you need to get the oAuth token.
- Spin up your web server listening to the url you configured as your redirect url in your Twitch application settings
- Send the user to the Auth URL using your WebBrowser control
- The user will have to enter their credentials, and maybe Two Factor auth details
- On a successful attempt your web server should then get a callback
- The callback for Authorization Code Flow contains a code
- Using the piece of code I posted you can make the final POST to Twitch and get the oAuth token back in the Json response.
I am planning on writing a small sample for this as I went through quite a few iterations before I got it working, in the mean time I hope this helps.