Added optionak scopes parameter

This commit is contained in:
Zach Teutsch 2022-01-25 22:21:14 -08:00
Родитель 14b8c1574f
Коммит 69a8fb7966
4 изменённых файлов: 8 добавлений и 6 удалений

Просмотреть файл

@ -184,16 +184,17 @@ namespace CommunityToolkit.Authentication
}
/// <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)

Просмотреть файл

@ -52,7 +52,7 @@ namespace CommunityToolkit.Authentication
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();

Просмотреть файл

@ -39,8 +39,9 @@ namespace CommunityToolkit.Authentication
/// 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 param 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.

Просмотреть файл

@ -52,7 +52,7 @@ namespace CommunityToolkit.Authentication
}
/// <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>");
}