コード例 #1
0
        public async Task LoginIfNeeded(BlueClient client, CancellationToken token = default)
        {
            if (_creds != null && DateTime.UtcNow < _creds.Expiration.AddMinutes(-5))
            {
                return;
            }

            // Re-login
            LoginResponse credentials = await client.LoginWithUsernamePassword(_username, _password, token);

            _creds = credentials.Credentials;
            _immutableCredentials = new ImmutableCredentials(_creds.AccessKey, _creds.SecretKey, _creds.SessionToken);
        }