自 v107 起在 RestSharp 上使用 NTLM/Kerberos

Mar*_*ger 5 c# rest windows-authentication restsharp ntlm-authentication

NtlmAuthenticator一段时间以来, of似乎RestSharp已被弃用。某处提到的设置方法setting.UseDefaultCredentials = true;也不可用。

那么我该如何使用NTLMor KerberoswithRestSharp呢?
和不!我不能说我想使用的其他程序LDAP或OAuth2.0任何您认为合适的程序。我有一个程序说:“我有一个 API,你可以授权LDAP/Kerberos,然后你就可以获取数据!” 我不是该 API 的程序员。

有谁知道如何使用较新版本的 RestSharp 获取我的数据,还是我必须返回到旧版本?

Ale*_*rev 1

与您所说的不同,两者Credentials都UseDefaultCredentials可用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; }
Run Code Online (Sandbox Code Playgroud)