Removed scopes param from IProvider.GetTokenAsync (#122)

This commit is contained in:
Shane Weaver 2021-07-12 14:56:40 -07:00 коммит произвёл GitHub
Родитель b663056345
Коммит 603137b5a0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 9 добавлений и 14 удалений

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

@ -119,17 +119,15 @@ namespace CommunityToolkit.Authentication
}
/// <inheritdoc/>
public override async Task<string> GetTokenAsync(bool silentOnly = false, string[] scopes = null)
public override async Task<string> GetTokenAsync(bool silentOnly = false)
{
var tokenScopes = scopes ?? Scopes;
AuthenticationResult authResult = null;
try
{
var account = _account ?? (await Client.GetAccountsAsync()).FirstOrDefault();
if (account != null)
{
authResult = await Client.AcquireTokenSilent(tokenScopes, account).ExecuteAsync();
authResult = await Client.AcquireTokenSilent(Scopes, account).ExecuteAsync();
}
}
catch (MsalUiRequiredException)
@ -145,7 +143,7 @@ namespace CommunityToolkit.Authentication
{
try
{
authResult = await Client.AcquireTokenInteractive(tokenScopes).WithPrompt(Prompt.SelectAccount).ExecuteAsync();
authResult = await Client.AcquireTokenInteractive(Scopes).WithPrompt(Prompt.SelectAccount).ExecuteAsync();
}
catch
{

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

@ -172,7 +172,7 @@ namespace CommunityToolkit.Authentication
}
/// <inheritdoc />
public override async Task<string> GetTokenAsync(bool silentOnly = false, string[] scopes = null)
public override async Task<string> GetTokenAsync(bool silentOnly = false)
{
var internetConnectionProfile = NetworkInformation.GetInternetConnectionProfile();
if (internetConnectionProfile == null)
@ -184,10 +184,8 @@ namespace CommunityToolkit.Authentication
try
{
var tokenScopes = scopes ?? _scopes;
// Attempt to authenticate silently.
var authResult = await AuthenticateSilentAsync(tokenScopes);
var authResult = await AuthenticateSilentAsync(_scopes);
// Authenticate with user interaction as appropriate.
if (authResult?.ResponseStatus != WebTokenRequestStatus.Success)
@ -199,7 +197,7 @@ namespace CommunityToolkit.Authentication
}
// Attempt to authenticate interactively.
authResult = await AuthenticateInteractiveAsync(tokenScopes);
authResult = await AuthenticateInteractiveAsync(_scopes);
}
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, string[] scopes = null);
public abstract Task<string> GetTokenAsync(bool silentOnly = false);
/// <inheritdoc />
public abstract Task SignInAsync();

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

@ -39,9 +39,8 @@ 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">Additional scopes to request access for.</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.

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

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