Some applications spin up a local web server and redirect back to localhost with the authorization code grant flow. You could also use the implicit grant flow - open a webview (or whatever the equivalent is in WPF) and grab the token from the URL hash after the redirect.
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:
If you are hosting the web browser internally in your app with any of the various browsers that allow that, you actually don’t need a live web server running. You can catch the Navigating event and parse the url that is being redirected to as the token you need is one of the url parameters and not embedded into the body.
You should modify your GitHub ASAP as it contains the Client Secret ID. Client ID is one thing to show but the secret ID should be kept from the public 100% of the time I believe.
Thanks @Larklen I’ve already invalidated the client secret. It’s so difficult to know what to do in these situations as you want to post working code but not post working application data if you see what I mean.
Could you elaborate a bit more? From what I can tell the Authorization flows always make a callback which means that you always need to be listening on the callback URL to be able to complete the Authentication and get access to the token? From my understanding (and happy to be corrected) that means you always need to have some kind of limited web server running.
Hmm, I whipped up an example and either the auth flow has changed or my test has a web server at that address (but it doesn’t participate). Sorry for the confusion.