Skip to content

Commit

Permalink
Extend XboxWebApi.Cli for passing RedirectURL as cmdline argument
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxuser committed Jun 7, 2018
1 parent b0e0cc5 commit e19003b
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions XboxWebApi.Cli/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.IO;
using XboxWebApi.Extensions;
using XboxWebApi.Authentication;
using XboxWebApi.Authentication.Model;

Expand All @@ -8,17 +10,27 @@ class Program
{
static void Main(string[] args)
{
string requestUrl = AuthenticationService.GetWindowsLiveAuthenticationUrl();
string responseUrl;
string requestUrl = AuthenticationService.GetWindowsLiveAuthenticationUrl();

Console.WriteLine("1) Open following URL in your WebBrowser:\n\n{0}\n\n" +
"2) Authenticate with your Microsoft Account\n" +
"3) Paste returned URL from addressbar: \n", requestUrl);
if (args.Length < 1)
{
Console.WriteLine("1) Open following URL in your WebBrowser:\n\n{0}\n\n" +
"2) Authenticate with your Microsoft Account\n" +
"3) Paste returned URL from addressbar: \n", requestUrl);

// Caveat: Console.ReadLine() is limited to 254 chars on Windows
responseUrl = Console.ReadLine();
}
else
{
responseUrl = args[0];
}

string responseUrl = Console.ReadLine();
WindowsLiveResponse response = AuthenticationService.ParseWindowsLiveResponse(responseUrl);
WindowsLiveResponse response = AuthenticationService.ParseWindowsLiveResponse(responseUrl);

AuthenticationService authenticator = new AuthenticationService(
new AccessToken(response), new RefreshToken(response));
AuthenticationService authenticator = new AuthenticationService(
new AccessToken(response), new RefreshToken(response));

bool success = authenticator.Authenticate();
if (!success)
Expand Down

0 comments on commit e19003b

Please sign in to comment.