Пример #1
0
        public AccessTokenDto Fetch(string authorizationId, string clientSecret)
        {
            string accessToken = string.Empty;
            AuthorizationConnector authConnector = null;

            try {
                authConnector = new AuthorizationConnector();
                accessToken   = authConnector.GetAccessToken(authorizationId, clientSecret);

                //accessToken = new AuthorizationConnector().GetAccessToken(authorizationId, clientSecret);
                //accessToken = new AuthorizationConnector().GetAccessToken(AuthorizationId, ClientSecret);

                if (accessToken == string.Empty)
                {
                    accessToken = "Denna AuthorizationCode är redan använd, eller har gått ut (giltighetstid = 30 dagar).";
                }
            }
            catch (Exception ex) {
                accessToken = ex.Message;
            }

            //return accessToken;
            return(new AccessTokenDto {
                AccessToken = accessToken,
                HasError = authConnector.HasError ? true : false
            });
        }
Пример #2
0
        public void TestAuth()
        {
            var authorizationCode = "Placeholder";
            var authConnector     = new AuthorizationConnector();
            var token             = authConnector.GetAccessToken(authorizationCode, TestCredentials.Client_Secret);

            MyAssert.HasNoError(authConnector);
            Assert.IsNotNull(token);
        }
Пример #3
0
        public AccessTokenDto Fetch(string authorizationId, string clientSecret)
        {
            string accessToken = string.Empty;
            AuthorizationConnector authConnector = null;

            try {
                authConnector = new AuthorizationConnector();
                // The following line is the real one to use in live environment
                accessToken = authConnector.GetAccessToken(authorizationId, clientSecret);

                // TEST AREA

                //accessToken = "a6bb30c2-b954-46bf-9c37-83cc9c65f173";

                //var custConnector = new CustomerConnector();
                //custConnector.AccessToken = accessToken;
                //custConnector.ClientSecret = clientSecret;
                //var c = custConnector.Find();

                //var companyConnector = new FortnoxAPILibrary.CompanySettingsConnector();
                //companyConnector.AccessToken = accessToken;
                //companyConnector.ClientSecret = clientSecret;
                //var c =  companyConnector.Get();

                //var contractConnector = new ContractConnector();
                //contractConnector.AccessToken = accessToken;
                //contractConnector.ClientSecret = clientSecret;
                //var res = contractConnector.Find();

                //var costCenterConn = new CostCenterConnector();
                //var supplierConn = new SupplierConnector();

                //costCenterConn.AccessToken = accessToken;
                //supplierConn.AccessToken = accessToken;
                //costCenterConn.ClientSecret = clientSecret;
                //supplierConn.ClientSecret = clientSecret;

                //var c = costCenterConn.Find();
                //var s = supplierConn.Find();

                // END OF TEST AREA

                if (accessToken == string.Empty)
                {
                    accessToken = "Denna AuthorizationCode är redan använd, eller har gått ut (giltighetstid = 30 dagar).";
                }
            }
            catch (Exception ex) {
                accessToken = ex.Message;
            }

            return(new AccessTokenDto {
                AccessToken = accessToken,
                HasError = authConnector.HasError ? true : false
            });
        }