Represents the Athorization credentials to be sent on every request to the nuxeo server.
Example #1
0
 /// <summary>
 /// Sets the authorization information to be sent in all requests.
 /// </summary>
 /// <param name="auth">The authorization data.</param>
 /// <returns>The current <see cref="Client"/> instace.</returns>
 public Client SetAuthorization(Authorization auth)
 {
     Authorization = auth ?? new Authorization();
     string authorizationHeaderValue = Authorization.GenerateAuthorizationParameter();
     if (http.DefaultRequestHeaders.Contains("Authorization"))
     {
         http.DefaultRequestHeaders.Remove("Authorization");
     }
     http.DefaultRequestHeaders.Add("Authorization", authorizationHeaderValue);
     return this;
 }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the Nuxeo <see cref="Client"/>.
 /// </summary>
 /// <param name="serverURL">The URL of the Nuxeo server.</param>
 /// <param name="authorization">The authorization credentials.</param>
 /// <param name="automationPath">The Automation API path.</param>
 /// <param name="restPath">The REST API path.</param>
 /// <param name="schemas">The default schemas to be used in the requests.</param>
 /// <param name="timeout">The default request timeout.</param>
 public Client(string serverURL = "http://localhost:8080/nuxeo/",
               Authorization authorization = null,
               string automationPath = "api/v1/automation/",
               string restPath = "api/v1/",
               string[] schemas = null,
               int timeout = 30)
 {
     http = new HttpClient(new HttpClientHandler()
     {
         AutomaticDecompression = System.Net.DecompressionMethods.None,
         AllowAutoRedirect = false
     });
     SetTimemout(timeout);
     SetServerURL(serverURL);
     SetAuthorization(authorization);
     SetAuthomationPath(automationPath);
     SetRestPath(restPath);
     SetAuthorization(authorization);
     http.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(ContentType.ALL));
     Marshaller = new Marshaller(this).RegisterEntity("workflow", typeof(Workflow))
                                      .RegisterEntity("worflows", typeof(Workflows))
                                      .RegisterEntity("task", typeof(NuxeoClient.Wrappers.Task))
                                      .RegisterEntity("tasks", typeof(Tasks));
 }