public async Task AuthenticateAsync()

in src/PowerShell/Factories/AuthenticationFactory.cs [34:63]


        public async Task<AuthenticationResult> AuthenticateAsync(PartnerAccount account, PartnerEnvironment environment, IEnumerable<string> scopes, string message = null, CancellationToken cancellationToken = default)
        {
            AuthenticationResult authResult = null;
            IAuthenticator processAuthenticator = Builder.Authenticator;

            while (processAuthenticator != null && authResult == null)
            {
                authResult = await processAuthenticator.TryAuthenticateAsync(GetAuthenticationParameters(account, environment, scopes, message), cancellationToken).ConfigureAwait(false);

                if (authResult != null)
                {
                    if (authResult.Account?.HomeAccountId != null)
                    {
                        account.Identifier = authResult.Account.HomeAccountId.Identifier;
                        account.ObjectId = authResult.Account.HomeAccountId.ObjectId;
                    }

                    if (account.Tenant.Equals("organizations", StringComparison.InvariantCultureIgnoreCase) && !string.IsNullOrEmpty(authResult.TenantId))
                    {
                        account.Tenant = authResult.TenantId;
                    }

                    break;
                }

                processAuthenticator = processAuthenticator.NextAuthenticator;
            }

            return authResult;
        }