Esempio n. 1
0
        static XeroApiHelper()
        {
            // Refer to README.md for details
            var callbackUrl = "http://mywebsite.url/Home/Authorize";
            var memoryStore = new MemoryAccessTokenStore();
            var requestTokenStore = new MemoryRequestTokenStore();
            var baseApiUrl = "https://api.xero.com";
            var basePartnerApiUrl = "https://api-partner.network.xero.com";

            var signingCertificatePath = @"C:\Dev\your_public_privatekey.pfx";
            var signingCertificatePassword = "******";
            var clientCertificatePath = @"C:\Dev\your_entrust_cert.p12";
            var clientCertificatePassword = "******";

            var publicAppConsumerKey = "your-public-app-consumer-key";
            var publicAppConsumerSecret = "your-public-app-consumer-secret";
            var partnerConsumerKey = "your-partner-app-consumer-key";
            var partnerConsumerSecret = "your-partner-app-consumer-secret";

            // Public Application Settings
            var publicConsumer = new Consumer(publicAppConsumerKey, publicAppConsumerSecret);

            var publicAuthenticator = new PublicMvcAuthenticator(baseApiUrl, baseApiUrl, callbackUrl, memoryStore, 
                publicConsumer, requestTokenStore);

            var publicApplicationSettings = new ApplicationSettings
                {
                    BaseApiUrl = baseApiUrl,
                    Consumer = publicConsumer,
                    Authenticator = publicAuthenticator
                };

            // Partner Application Settings
            var partnerConsumer = new Consumer(partnerConsumerKey, partnerConsumerSecret);

            var partnerAuthenticator = new PartnerMvcAuthenticator(basePartnerApiUrl, baseApiUrl, callbackUrl,
                    memoryStore, signingCertificatePath, clientCertificatePath, clientCertificatePassword, 
                    partnerConsumer, requestTokenStore, signingCertificatePassword);

            var partnerApplicationSettings = new ApplicationSettings
            {
                BaseApiUrl = basePartnerApiUrl,
                Consumer = partnerConsumer,
                Authenticator = partnerAuthenticator
            };

            // Pick one
            // Choose what sort of application is appropriate. Comment out the above code (Partner Application Settings/Public Application Settings) that are not used.

            //_applicationSettings = publicApplicationSettings;
            _applicationSettings = partnerApplicationSettings;
        }
Esempio n. 2
0
        static XeroApiHelper()
        {
            var callbackUrl = "your-callback-url";
            var memoryStore = new MemoryAccessTokenStore();
            var requestTokenStore = new MemoryRequestTokenStore();
            var baseApiUrl = "https://api.xero.com";
            var basePartnerApiUrl = "https://api-partner.network.xero.com";

            var signingCertificatePath = @"C:\Dev\your_public_privatekey.pfx";
            var clientCertificatePath = @"C:\Dev\your_entrust_cert.p12";
            var clientCertificatePassword = "******";

            var publicAppConsumerKey = "your-public-app-consumer-key";
            var publicAppConsumerSecret = "your-public-app-consumer-secret";
            var partnerConsumerKey = "your-partner-app-consumer-key";
            var partnerConsumerSecret = "your-partner-app-consumer-secret";

            // Public Application Settings
            var publicConsumer = new Consumer(publicAppConsumerKey, publicAppConsumerSecret);

            var publicAuthenticator = new PublicMvcAuthenticator(baseApiUrl, baseApiUrl, callbackUrl, memoryStore,
                publicConsumer, requestTokenStore);

            var publicApplicationSettings = new ApplicationSettings
                {
                    BaseApiUrl = baseApiUrl,
                    Consumer = publicConsumer,
                    Authenticator = publicAuthenticator
                };

            // Partner Application Settings
            var partnerConsumer = new Consumer(partnerConsumerKey, partnerConsumerSecret);

            var partnerAuthenticator = new PartnerMvcAuthenticator(basePartnerApiUrl, baseApiUrl, callbackUrl,
                    memoryStore, signingCertificatePath, clientCertificatePath, clientCertificatePassword,
                    partnerConsumer, requestTokenStore);

            var partnerApplicationSettings = new ApplicationSettings
            {
                BaseApiUrl = basePartnerApiUrl,
                Consumer = publicConsumer,
                Authenticator = partnerAuthenticator
            };

            // Pick one

            //_applicationSettings = publicApplicationSettings;
            _applicationSettings = partnerApplicationSettings;
        }