Beispiel #1
0
        public async Task <string> GetAccessTokenFromPin(int pinId)
        {
            var pin = await _api.GetPin(pinId);

            if (pin.expiresAt < DateTime.UtcNow)
            {
                return(string.Empty);
            }

            if (pin.authToken.IsNullOrEmpty())
            {
                // Looks like we do not have a pin yet, we should retry a few times.
                var retryCount  = 0;
                var retryMax    = 5;
                var retryWaitMs = 1000;
                while (pin.authToken.IsNullOrEmpty() && retryCount < retryMax)
                {
                    retryCount++;
                    await Task.Delay(retryWaitMs);

                    pin = await _api.GetPin(pinId);
                }
            }
            return(pin.authToken);
        }
Beispiel #2
0
        public async Task <string> GetAccessTokenFromPin(int pinId)
        {
            var pin = await _api.GetPin(pinId);

            if (pin.expiresAt < DateTime.UtcNow)
            {
                return(string.Empty);
            }

            return(pin.authToken);
        }
Beispiel #3
0
        public async Task <string> GetAccessTokenFromPin(int pinId)
        {
            var pin = await _api.GetPin(pinId);

            if (pin.Errors != null)
            {
                foreach (var err in pin.Errors?.errors ?? new List <OAuthErrors>())
                {
                    _logger.LogError($"Code: '{err.code}' : '{err.message}'");
                }

                return(string.Empty);
            }

            if (pin.Result.expiresIn <= 0)
            {
                _logger.LogError("Pin has expired");
                return(string.Empty);
            }

            return(pin.Result.authToken);
        }