Ejemplo n.º 1
0
        public XeroPrivateApplication(string key, string secret, string pfxFile, string pfxPassword)
        {
            EndpointAddress endpointAddress = new EndpointAddress("https://api.xero.com/api.xro/2.0/");

            IPHostEntry hostEntry = Dns.GetHostEntry(endpointAddress.Uri.DnsSafeHost);

            if (hostEntry.AddressList.Length == 0)
                throw new NotSupportedException("Unable to resolve host");

            OAuthClientCredentials credentials = new OAuthClientCredentials();
            credentials.OAuthKey = key;
            credentials.OAuthToken = key;
            credentials.OAuthSecret = secret;
            credentials.OAuthTokenSecret = secret;
            credentials.OAuthPfxFile = pfxFile;
            credentials.OAuthPfxPassword = pfxPassword;
            credentials.OAuthRealm = hostEntry.AddressList[0].ToString();

            _client = new XeroClient(endpointAddress, credentials);
        }
Ejemplo n.º 2
0
 public OAuthMessageInspector(OAuthClientCredentials credentials)
 {
     _credentials = credentials;
     _nonceProvider = new GuidNonceProvider();
 }
Ejemplo n.º 3
0
        public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
        {
            _credentials = endpoint.Behaviors.OfType<OAuthClientCredentials>().First();

            clientRuntime.MessageInspectors.Add(new OAuthMessageInspector(_credentials));
        }