Search code examples
c#restwindows-authenticationrestsharpntlm-authentication

Using NTLM/Kerberos on RestSharp since v107


Since some time it seems the NtlmAuthenticator of RestSharp is deprecated. The somewhere mentioned method of setting setting.UseDefaultCredentials = true; isn't available either.

So how can I use NTLM or Kerberos with RestSharp?
AND NO! I cannot say the other program, that I want to use LDAP or OAuth2.0 or whatever you think is appropriate. I have a program that says: "I have an API and you can authorize by LDAP/Kerberos and then you get data!" and I am not the programmer of that API.

Has anyone an idea of how to get my data with the newer versions of RestSharp or do I have to go back to old versions?


Solution

  • Both Credentials and UseDefaultCredentials are available, unlike you said, in RestClientOptions:

    https://github.com/restsharp/RestSharp/blob/8b388fbe832633d5c89e2a42e5cf078aa36e6a28/src/RestSharp/RestClientOptions.cs#L44-L53

    /// <summary>
    /// In general you would not need to set this directly. Used by the NtlmAuthenticator.
    /// </summary>
    public ICredentials? Credentials { get; set; }
    
    /// <summary>
    /// Determine whether or not the "default credentials" (e.g. the user account under which the current process is
    /// running) will be sent along to the server. The default is false.
    /// </summary>
    public bool UseDefaultCredentials { get; set; }