My example will be strongly base off the work MS has already done and published in Github, the main elements that my sample code will add is a service and a event that is fired when we receive the Oauth token.
First I wanted to create a service, so I create an interface as follows:
I have create the MsTokenReceived event as it will allow me to pass the information that I have received my token and thus can continue to try and log the user.
First we create our class: (MicrosoftService.cs)
public class MicrosoftService : IMicrosoftService
You will find or create your AccountClientId here https://apps.dev.microsoft.com/#/appList
Click on Add App, fill in the necessary information, add a platform (here under platform I have added a Native Application)
and click Save.
Now back to our app, in our class MicrosoftService.cs, we will add the method:
Again this is exactly what you will find in the windows sample, except for when you want to run your application on an Xbox.
This is a simple copy and paste of the code from the MS sample.
the only added code is this:
which allows me to send the information back to the app that we have received the Oauth token, here I send back a string that is the Oauth token but you can send back whatever you wish.
For the Xbox we must find the default provider with only the ClientId:
Now we just need to instantiate our class call the LogIntoMicrosoftService method for the IMicrosoftService and wait for the MsTokenReceived event to be fire for the login to have worked