Skip to content

Commit

Permalink
Merge pull request #184 from CommunityToolkit/revert-183-add-sources-arg
Browse files Browse the repository at this point in the history
Revert "Add optional Scopes parameter to BaseProvider"
  • Loading branch information
michael-hawker authored Feb 15, 2022
2 parents 42f6b75 + bac18c5 commit 15513b1
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
5 changes: 2 additions & 3 deletions CommunityToolkit.Authentication.Msal/MsalProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,9 @@ public override async Task SignOutAsync()
}

/// <inheritdoc/>
public override Task<string> GetTokenAsync(bool silentOnly = false, string[] scopes = null)
public override Task<string> GetTokenAsync(bool silentOnly = false)
{
var withScopes = scopes ?? this.Scopes;
return this.GetTokenWithScopesAsync(withScopes, silentOnly);
return this.GetTokenWithScopesAsync(Scopes, silentOnly);
}

/// <summary>
Expand Down
7 changes: 3 additions & 4 deletions CommunityToolkit.Authentication.Uwp/WindowsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,16 @@ public override async Task SignOutAsync()
}

/// <inheritdoc />
public override async Task<string> GetTokenAsync(bool silentOnly = false, string[] scopes = null)
public override async Task<string> GetTokenAsync(bool silentOnly = false)
{
await SemaphoreSlim.WaitAsync();

try
{
// use request specific scopes if not null, otherwise use class scopes
var authenticationScopes = scopes ?? this._scopes;
var scopes = _scopes;

// Attempt to authenticate silently.
var authResult = await AuthenticateSilentAsync(authenticationScopes);
var authResult = await AuthenticateSilentAsync(scopes);

// Authenticate with user interaction as appropriate.
if (authResult?.ResponseStatus != WebTokenRequestStatus.Success)
Expand Down
2 changes: 1 addition & 1 deletion CommunityToolkit.Authentication/BaseProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public BaseProvider()
public abstract Task AuthenticateRequestAsync(HttpRequestMessage request);

/// <inheritdoc />
public abstract Task<string> GetTokenAsync(bool silentOnly = false, string[] scopes = null);
public abstract Task<string> GetTokenAsync(bool silentOnly = false);

/// <inheritdoc />
public abstract Task SignInAsync();
Expand Down
3 changes: 1 addition & 2 deletions CommunityToolkit.Authentication/IProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ public interface IProvider
/// Retrieve a token for the authenticated user.
/// </summary>
/// <param name="silentOnly">Determines if the acquisition should be done without prompts to the user.</param>
/// <param name="scopes"> Optional parameter for setting scopes specific to this token request. </param>
/// <returns>A token string for the authenticated user.</returns>
Task<string> GetTokenAsync(bool silentOnly = false, string[] scopes = null);
Task<string> GetTokenAsync(bool silentOnly = false);

/// <summary>
/// Sign in the user.
Expand Down
2 changes: 1 addition & 1 deletion CommunityToolkit.Authentication/MockProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public override async Task AuthenticateRequestAsync(HttpRequestMessage request)
}

/// <inheritdoc/>
public override Task<string> GetTokenAsync(bool silentOnly = false, string[] scopes = null)
public override Task<string> GetTokenAsync(bool silentOnly = false)
{
return Task.FromResult("<mock-provider-token>");
}
Expand Down

0 comments on commit 15513b1

Please sign in to comment.