Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CommunityToolkit.Authentication.Msal/MsalProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,10 @@ public override async Task SignOutAsync()
}

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

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

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

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

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

// 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);
public abstract Task<string> GetTokenAsync(bool silentOnly = false, string[] scopes = null);

/// <inheritdoc />
public abstract Task SignInAsync();
Expand Down
3 changes: 2 additions & 1 deletion CommunityToolkit.Authentication/IProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ 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);
Task<string> GetTokenAsync(bool silentOnly = false, string[] scopes = null);

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