Add -token functionality

pull/599/head
bt 10 months ago
parent 7b3cf4c6c7
commit 74b9e27a04

@ -300,11 +300,11 @@ namespace DepotDownloader
return info["name"].AsString();
}
public static bool InitializeSteam3(string username, string password)
public static bool InitializeSteam3(string username, string password, string token)
{
string loginToken = null;
string loginToken = token;
if (username != null && Config.RememberPassword)
if (username != null && Config.RememberPassword && loginToken == null)
{
_ = AccountSettingsStore.Instance.LoginTokens.TryGetValue(username, out loginToken);
}

@ -62,6 +62,8 @@ namespace DepotDownloader
var username = GetParameter<string>(args, "-username") ?? GetParameter<string>(args, "-user");
var password = GetParameter<string>(args, "-password") ?? GetParameter<string>(args, "-pass");
var token = GetParameter<string>(args, "-token");
ContentDownloader.Config.RememberPassword = HasParameter(args, "-remember-password");
ContentDownloader.Config.UseQrCode = HasParameter(args, "-qr");
@ -170,7 +172,7 @@ namespace DepotDownloader
{
#region Pubfile Downloading
if (InitializeSteam(username, password))
if (InitializeSteam(username, password, token))
{
try
{
@ -205,7 +207,7 @@ namespace DepotDownloader
{
#region UGC Downloading
if (InitializeSteam(username, password))
if (InitializeSteam(username, password, token))
{
try
{
@ -295,7 +297,7 @@ namespace DepotDownloader
depotManifestIds.AddRange(depotIdList.Select(depotId => (depotId, ContentDownloader.INVALID_MANIFEST_ID)));
}
if (InitializeSteam(username, password))
if (InitializeSteam(username, password, token))
{
try
{
@ -330,11 +332,11 @@ namespace DepotDownloader
return 0;
}
static bool InitializeSteam(string username, string password)
static bool InitializeSteam(string username, string password, string token)
{
if (!ContentDownloader.Config.UseQrCode)
{
if (username != null && password == null && (!ContentDownloader.Config.RememberPassword || !AccountSettingsStore.Instance.LoginTokens.ContainsKey(username)))
if (token == null && username != null && password == null && (!ContentDownloader.Config.RememberPassword || !AccountSettingsStore.Instance.LoginTokens.ContainsKey(username)))
{
do
{
@ -356,9 +358,13 @@ namespace DepotDownloader
{
Console.WriteLine("No username given. Using anonymous account with dedicated server subscription.");
}
else if (token != null)
{
return ContentDownloader.InitializeSteam3(username, null, token);
}
}
return ContentDownloader.InitializeSteam3(username, password);
return ContentDownloader.InitializeSteam3(username, password, null);
}
static int IndexOfParam(string[] args, string param)
@ -455,6 +461,7 @@ namespace DepotDownloader
Console.WriteLine();
Console.WriteLine(" -username <user> - the username of the account to login to for restricted content.");
Console.WriteLine(" -password <pass> - the password of the account to login to for restricted content.");
Console.WriteLine(" -token <access_token> - login with a access token, bypasses the need for password or guard.");
Console.WriteLine(" -remember-password - if set, remember the password for subsequent logins of this user.");
Console.WriteLine(" use -username <username> -remember-password as login credentials.");
Console.WriteLine();

Loading…
Cancel
Save