コード例 #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);
        }
コード例 #2
0
 public OAuthMessageInspector(OAuthClientCredentials credentials)
 {
     _credentials = credentials;
     _nonceProvider = new GuidNonceProvider();
 }
コード例 #3
0
        public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
        {
            _credentials = endpoint.Behaviors.OfType<OAuthClientCredentials>().First();

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