public void OAuthAuthorizationCodeFlowTest()
        {
            // Initiate the browser session to the Authentication server
            // so the user can login.
            string accountServerAuthUrl = string.Format("https://{0}/oauth/auth?response_type=code&scope=all&client_id={1}&redirect_uri={2}&state=testState",
                                                        AccountServerHost,
                                                        client_id,
                                                        redirect_url,
                                                        stateOptional);
               System.Diagnostics.Process.Start(accountServerAuthUrl);

            WaitForCallbackEvent = new ManualResetEvent(false);

            // Launch a self-hosted web server to accepte the redirect_url call
            // after the user finishes authencation.
            using (WebApp.Start<Startup>("http://localhost:8090"))
            {
                Trace.WriteLine("WebServer Running- Waiting for access_token");

                // This waits for the redirect_url to be received in the REST controller
                // (see classes below) and then sleeps a short time to allow the response
                // to be returned to the web browser before the server session ends.
                WaitForCallbackEvent.WaitOne(60000, false);
                Thread.Sleep(1000);
            }

            Assert.IsNotNull(AccessCode);

            // The Authentication is completed, so now echange a code returned for
            // the access_token and refresh_token
            var webClient = new WebClient();

            webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");

            // Add the Authorization header with client_id and client_secret as base64
            string codeAuth = client_id + ":" + client_secret;
            byte[] codeAuthBytes = Encoding.UTF8.GetBytes(codeAuth);
            string codeAuthBase64 = Convert.ToBase64String(codeAuthBytes);
            webClient.Headers.Add("Authorization", "Basic " + codeAuthBase64);

            // Add the code returned from the Authentication site
            string tokenGrantAndCode = string.Format("grant_type=authorization_code&code={0}", AccessCode);

            // Call the token endpoint to exchange the code for an access_token
            string tokenEndpoint = string.Format("https://{0}/oauth/token", AccountServerHost);
            string tokenResponse = webClient.UploadString(tokenEndpoint, tokenGrantAndCode);
            TokenResponse tokenObj = JsonConvert.DeserializeObject<TokenResponse>(tokenResponse);

            Assert.IsNotNull(tokenObj);
            Assert.IsNotNull(tokenObj.access_token);
            Trace.WriteLine("Access_token: " + tokenObj.access_token);

            // Make an API call with the token
            ApiClient apiClient = new ApiClient(BaseUrl);

            DocuSign.eSign.Client.Configuration.Default.ApiClient = apiClient;
            DocuSign.eSign.Client.Configuration.Default.AddDefaultHeader("Authorization", "Bearer " + tokenObj.access_token);

            AccountsApi accountsApi = new AccountsApi();
            AccountInformation accountInformation = accountsApi.GetAccountInformation("1");
            Trace.WriteLine(accountInformation.ToString());

            // Generally the refresh token is stored away and used to get a new access_token without authenticating via the browser
            // when the access_token expires (see expires_in). Here we test that the refresh_token can be
            // exchanged for a new access_token

            webClient = new WebClient();
            webClient.Headers.Add("Authorization", "Basic " + codeAuthBase64);
            webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");

            // Add the code returned from the Authentication site
            string refreshGrant = string.Format("grant_type=refresh_token&refresh_token={0}", tokenObj.refresh_token);
            tokenResponse = webClient.UploadString(tokenEndpoint, refreshGrant);
            tokenObj = JsonConvert.DeserializeObject<TokenResponse>(tokenResponse);

            Assert.IsNotNull(tokenObj);
            Assert.IsNotNull(tokenObj.access_token);
            Trace.WriteLine("Access_token (After Refresh): " + tokenObj.access_token);

            // Try another call with new acccess token
            accountInformation = accountsApi.GetAccountInformation("1");
            Trace.WriteLine(accountInformation.ToString());
        }
        /// <summary>
        /// Retrieves the account information for the specified account. Retrieves the account information for the specified account.\n\n**Response**\nThe `canUpgrade` property contains is a Boolean that indicates whether the account can be upgraded through the API.
        /// </summary>
 	    ///<param name="accountId">The external account number (int) or account ID Guid.</param> <param name="options">Options for modifying the behavior of the function.</param>
		/// <returns>7Task of AccountInformation</returns>
        public async System.Threading.Tasks.Task<AccountInformation> GetAccountInformationAsync (string accountId, AccountsApi.GetAccountInformationOptions options = null)
        {
             ApiResponse<AccountInformation> response = await GetAccountInformationAsyncWithHttpInfo(accountId, options);
             return response.Data;

        }
        /// <summary>
        /// Retrieves the account information for the specified account. Retrieves the account information for the specified account.\n\n**Response**\nThe `canUpgrade` property contains is a Boolean that indicates whether the account can be upgraded through the API.
        /// </summary>
	    ///<param name="accountId">The external account number (int) or account ID Guid.</param> <param name="options">Options for modifying the behavior of the function.</param>
		/// <returns>8Task of ApiResponse (AccountInformation)</returns>
        public async System.Threading.Tasks.Task<ApiResponse<AccountInformation>> GetAccountInformationAsyncWithHttpInfo (string accountId, AccountsApi.GetAccountInformationOptions options = null)
        {
            // verify the required parameter 'accountId' is set
            if (accountId == null) throw new ApiException(400, "Missing required parameter 'accountId' when calling GetAccountInformation");
            
    
            var path_ = "/v2/accounts/{accountId}";
    
            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>();
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            String postBody = null;

            // to determine the Accept header
            String[] http_header_accepts = new String[] {
                "application/json"
            };
            String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts);
            if (http_header_accept != null)
                headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts));

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            pathParams.Add("format", "json");
            if (accountId != null) pathParams.Add("accountId", Configuration.ApiClient.ParameterToString(accountId)); // path parameter
            

						
			if (options != null)
			{
				if (options.includeAccountSettings != null) queryParams.Add("include_account_settings", Configuration.ApiClient.ParameterToString(options.includeAccountSettings)); // query parameter
				if (options.op != null) queryParams.Add("op", Configuration.ApiClient.ParameterToString(options.op)); // query parameter
				
			}
			

            
            
            

            

            // make the HTTP request
            IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams);

            int statusCode = (int) response.StatusCode;
 
            if (statusCode >= 400)
                throw new ApiException (statusCode, "Error calling GetAccountInformation: " + response.Content, response.Content);
            else if (statusCode == 0)
                throw new ApiException (statusCode, "Error calling GetAccountInformation: " + response.ErrorMessage, response.ErrorMessage);

            return new ApiResponse<AccountInformation>(statusCode,
                response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                (AccountInformation) Configuration.ApiClient.Deserialize(response, typeof(AccountInformation)));
            
        }
        /// <summary>
        /// Retrieves the account information for the specified account. Retrieves the account information for the specified account.\n\n**Response**\nThe `canUpgrade` property contains is a Boolean that indicates whether the account can be upgraded through the API.
        /// </summary>
 	    ///<param name="accountId">The external account number (int) or account ID Guid.</param> <param name="options">Options for modifying the behavior of the function.</param>
		/// <returns>5AccountInformation</returns>
        public AccountInformation GetAccountInformation (string accountId, AccountsApi.GetAccountInformationOptions options = null)
        {
             ApiResponse<AccountInformation> response = GetAccountInformationWithHttpInfo(accountId, options);
             return response.Data;
        }