public async Task <IEnumerable <IAccount> > GetAccountsAsync(string clientID, string redirectUri)
        {
            using (_logger.LogMethodDuration())
            {
                if (!IsBrokerInstalledAndInvokable())
                {
                    _logger.Warning("Android broker is either not installed or is not reachable so no accounts will be returned. ");
                    return(new List <IAccount>());
                }

                BrokerRequest brokerRequest = new BrokerRequest()
                {
                    ClientId = clientID, RedirectUri = new Uri(redirectUri)
                };

                try
                {
                    await _brokerHelper.InitiateBrokerHandshakeAsync(_parentActivity).ConfigureAwait(false);

                    return(_brokerHelper.GetBrokerAccountsInAccountManager(brokerRequest));
                }
                catch (Exception ex)
                {
                    _logger.Error("Failed to get Android broker accounts from the broker. ");
                    HandleBrokerOperationError(ex);
                    throw;
                }
            }
        }
Ejemplo n.º 2
0
        public async Task <IEnumerable <IAccount> > GetAccountsAsync(string clientID)
        {
            if (!IsBrokerInstalledAndInvokable())
            {
                _logger.Error("Android broker is not installed so no accounts will be returned.");
                return(new List <IAccount>());
            }

            Dictionary <string, string> brokerPayload = new Dictionary <string, string>();

            brokerPayload.Add(BrokerParameter.ClientId, clientID);

            try
            {
                await _brokerHelper.InitiateBrokerHandshakeAsync(_activity).ConfigureAwait(false);

                return(_brokerHelper.GetBrokerAccountsInAccountManager(brokerPayload));
            }
            catch (Exception ex)
            {
                _logger.Error("Failed to get Android broker accounts from the broker.");
                HandleBrokerOperationError(ex);
                throw;
            }
        }