Skip to content

Commit

Permalink
Merge pull request #283 from cvax/googleAuthToIni
Browse files Browse the repository at this point in the history
Move google auth token to "GoogleAuth.ini"
  • Loading branch information
NecronomiconCoding authored Jul 23, 2016
2 parents fc9c6cf + 014eed8 commit 781ab78
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 32 deletions.
3 changes: 0 additions & 3 deletions PokemonGo.RocketAPI.Console/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
<setting name="PtcPassword" serializeAs="String">
<value>pw</value>
</setting>
<setting name="GoogleRefreshToken" serializeAs="String">
<value />
</setting>
<setting name="DefaultLatitude" serializeAs="String">
<value>52.379189</value>
</setting>
Expand Down
10 changes: 0 additions & 10 deletions PokemonGo.RocketAPI.Console/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ public class Settings : ISettings
public bool UsePokemonToNotCatchFilter => UserSettings.Default.UsePokemonToNotCatchFilter;
public int KeepMinDuplicatePokemon => UserSettings.Default.KeepMinDuplicatePokemon;
public bool PrioritizeIVOverCP => UserSettings.Default.PrioritizeIVOverCP;

public string GoogleRefreshToken
{
get { return UserSettings.Default.GoogleRefreshToken; }
set
{
UserSettings.Default.GoogleRefreshToken = value;
UserSettings.Default.Save();
}
}

//Type and amount to keep
public ICollection<KeyValuePair<ItemId, int>> ItemRecycleFilter => new[]
Expand Down
12 changes: 0 additions & 12 deletions PokemonGo.RocketAPI.Console/UserSettings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions PokemonGo.RocketAPI.Console/UserSettings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
<Setting Name="PtcPassword" Type="System.String" Scope="User">
<Value Profile="(Default)">pw</Value>
</Setting>
<Setting Name="GoogleRefreshToken" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="DefaultLatitude" Type="System.Double" Scope="User">
<Value Profile="(Default)">52.379189</Value>
</Setting>
Expand Down
13 changes: 10 additions & 3 deletions PokemonGo.RocketAPI/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,25 @@ public async Task DoGoogleLogin()
{
_authType = AuthType.Google;

string googleRefreshToken = string.Empty;
if (File.Exists(Directory.GetCurrentDirectory() + "\\Configs\\GoogleAuth.ini"))
{
googleRefreshToken = File.ReadAllText(Directory.GetCurrentDirectory() + "\\Configs\\GoogleAuth.ini");
}

GoogleLogin.TokenResponseModel tokenResponse;
if (Settings.GoogleRefreshToken != string.Empty)
if (googleRefreshToken != string.Empty)
{
tokenResponse = await GoogleLogin.GetAccessToken(Settings.GoogleRefreshToken);
tokenResponse = await GoogleLogin.GetAccessToken(googleRefreshToken);
AccessToken = tokenResponse?.id_token;
}

if (AccessToken == null)
{
var deviceCode = await GoogleLogin.GetDeviceCode();
tokenResponse = await GoogleLogin.GetAccessToken(deviceCode);
Settings.GoogleRefreshToken = tokenResponse?.refresh_token;
googleRefreshToken = tokenResponse?.refresh_token;
File.WriteAllText(Directory.GetCurrentDirectory() + "\\Configs\\GoogleAuth.ini", googleRefreshToken);
Logger.Write("Refreshtoken " + tokenResponse?.refresh_token + " saved");
AccessToken = tokenResponse?.id_token;
}
Expand Down
1 change: 0 additions & 1 deletion PokemonGo.RocketAPI/ISettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public interface ISettings
double DefaultLatitude { get; }
double DefaultLongitude { get; }
double DefaultAltitude { get; }
string GoogleRefreshToken { get; set; }
string PtcPassword { get; }
string PtcUsername { get; }
float KeepMinIVPercentage { get; }
Expand Down

0 comments on commit 781ab78

Please sign in to comment.