Exemplo n.º 1
0
        private static bool ExpiresSoon(SuccessfulTokenResult token)
        {
            if (token == null)
            {
                throw new ArgumentNullException(nameof(token));
            }


            var exactTokenExpiresAt = token.TokenExpiresAt;

            if (DateTime.Now >= exactTokenExpiresAt - TimeSpan.FromMinutes(ExpirationBufferMinutes))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        private void ResetToken()
        {
            var formData = new FormUrlEncodedContent(new[]
            {
                _grantType
            });


            var apiResponse =
                Api.PostAsync <NewTokenResponse>(Endpoint, formData).Result;

            // ToDo: Don't leave this like this. I just don't know what to do yet
            // If any of this somehow fails.
            if (apiResponse == null)
            {
                throw new InvalidOperationException();
            }


            LastValidNewToken = new SuccessfulTokenResult(apiResponse);
        }