public async Task PinAuthorization_Authorize_UseApi_SaveRefreshToken_AuthorizeAgain()
        {
            // Create instance of authentication using one-time pin, which you retrieved before this step from iDoklad Web
            var initialAuthentication = new PinAuthentication(ClientId, ClientSecret, "pin");

            // Initialize context and api
            InitializeContextAndApi(initialAuthentication);

            // Use api as usual
            var agenda = await _api.AccountClient.Agendas.Current().GetAsync();

            var contact = await _api.ContactClient.Detail(123).GetAsync();

            // Before shutting down the application, save refresh token
            var refreshToken = initialAuthentication.RefreshToken;

            // Afterwards, when loading the application, use refresh token when creating authentication
            var subsequentAuthentication = new PinAuthentication(ClientId, ClientSecret, null, refreshToken);

            // Initialize context and api
            InitializeContextAndApi(subsequentAuthentication);

            // Use api as usual
            var issuedInvoice = await _api.IssuedInvoiceClient.DefaultAsync();
        }
        public async Task GetToken_SucessfullyAsync()
        {
            // Arrange
            var auth   = new PinAuthentication(Configuration.PinFlow.ClientId, Configuration.PinFlow.ClientSecret, Configuration.PinFlow.Pin, Configuration.PinFlow.RefreshToken);
            var config = new DokladConfiguration(Configuration.Urls.ApiUrl, Configuration.Urls.IdentityServerTokenUrl);

            auth.Configuration = config;

            // Act
            var token = await auth.RefreshAccessTokenAsync();

            // Assert
            Assert.IsNotNull(token);
            Assert.That(token.AccessToken, Is.Not.Null.Or.Empty);
        }
        public async Task PinAuthorization_RetrieveAndSaveRefreshToken()
        {
            // Create instance of authentication using one-time pin, which you retreived before this step from iDoklad Web
            var initialAuthentication = new PinAuthentication(ClientId, ClientSecret, "pin");

            // Request access token, with this call refresh token will be requested as well
            var tokenizer = await initialAuthentication.GetTokenAsync();

            // Retrieve refresh token (both values are the same) and save it
            var refreshToken1 = tokenizer.RefreshToken;
            var refreshToken2 = initialAuthentication.RefreshToken;

            // Afterwards, refresh token is used for authentication
            var subsequentAuthentication = new PinAuthentication(ClientId, ClientSecret, null, refreshToken1 ?? refreshToken2);

            // Initialize context and api
            InitializeContextAndApi(subsequentAuthentication);

            // Use api as usual
            var apiResult = await _api.IssuedInvoiceClient.DefaultAsync();

            var defaultIssuedInvoice = apiResult.Data;
        }