Skip to content

Commit

Permalink
Fix initialisation logic that incorrectly deletes token file.
Browse files Browse the repository at this point in the history
  • Loading branch information
phw198 committed Sep 5, 2024
1 parent f06e354 commit b50126b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/OutlookGoogleCalendarSync/Google/Authenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,12 @@ public static String HashedGmailAccount {
}
}

public Authenticator() {
CancelTokenSource = new System.Threading.CancellationTokenSource();
}
public Authenticator() { }

public void GetAuthenticated() {
if (this.authenticated) return;

CancelTokenSource = new System.Threading.CancellationTokenSource();
Forms.Main.Instance.Console.Update("<span class='em em-key'></span>Authenticating with Google", Console.Markup.h2, newLine: false, verbose: true);

System.Threading.Thread oAuth = new System.Threading.Thread(() => { spawnOauth(); });
Expand Down Expand Up @@ -120,7 +119,7 @@ private async Task<bool> getAuthenticated(ClientSecrets cs) {

UserCredential credential = null;
try {
if (!SufficientPermissions) File.Delete(tokenFullPath);
if (authenticated && !SufficientPermissions) File.Delete(tokenFullPath);

//This will open the authorisation process in a browser, if required
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(cs, requiredScopes, "user", CancelTokenSource.Token, tokenStore);
Expand Down

0 comments on commit b50126b

Please sign in to comment.