Merge branch 'main' into patch-1
This commit is contained in:
Коммит
9736890f36
|
@ -171,9 +171,10 @@ namespace CommunityToolkit.Authentication
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <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>
|
/// <summary>
|
||||||
|
|
|
@ -184,16 +184,17 @@ namespace CommunityToolkit.Authentication
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <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();
|
await SemaphoreSlim.WaitAsync();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var scopes = _scopes;
|
// use request specific scopes if not null, otherwise use class scopes
|
||||||
|
var authenticationScopes = scopes ?? this._scopes;
|
||||||
|
|
||||||
// Attempt to authenticate silently.
|
// Attempt to authenticate silently.
|
||||||
var authResult = await AuthenticateSilentAsync(scopes);
|
var authResult = await AuthenticateSilentAsync(authenticationScopes);
|
||||||
|
|
||||||
// Authenticate with user interaction as appropriate.
|
// Authenticate with user interaction as appropriate.
|
||||||
if (authResult?.ResponseStatus != WebTokenRequestStatus.Success)
|
if (authResult?.ResponseStatus != WebTokenRequestStatus.Success)
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace CommunityToolkit.Authentication
|
||||||
public abstract Task AuthenticateRequestAsync(HttpRequestMessage request);
|
public abstract Task AuthenticateRequestAsync(HttpRequestMessage request);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public abstract Task<string> GetTokenAsync(bool silentOnly = false);
|
public abstract Task<string> GetTokenAsync(bool silentOnly = false, string[] scopes = null);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public abstract Task SignInAsync();
|
public abstract Task SignInAsync();
|
||||||
|
|
|
@ -39,8 +39,9 @@ namespace CommunityToolkit.Authentication
|
||||||
/// Retrieve a token for the authenticated user.
|
/// Retrieve a token for the authenticated user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="silentOnly">Determines if the acquisition should be done without prompts to the user.</param>
|
/// <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>
|
/// <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>
|
/// <summary>
|
||||||
/// Sign in the user.
|
/// Sign in the user.
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace CommunityToolkit.Authentication
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <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>");
|
return Task.FromResult("<mock-provider-token>");
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче