Merge branch 'main' into patch-1

This commit is contained in:
Nikola Metulev 2022-01-26 14:35:54 -08:00 коммит произвёл GitHub
Родитель 64b2307fd5 e11fe162a8
Коммит 9736890f36
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 11 добавлений и 8 удалений

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

@ -171,9 +171,10 @@ namespace CommunityToolkit.Authentication
}
/// <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>

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

@ -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 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.

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

@ -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>");
}