Simple.Odata 客户端使用 windows 身份验证
Simple.Odata Client using windows authentification
可以使用简单的 Odata 客户端通过 windows 身份验证来请求我的 Odata 服务(由 Asp.Net MVC 托管)?
简单的 Odata 客户端需要凭据:
public ODataClient(ODataClientSettings settings);
public ODataClientSettings(Uri baseUri, ICredentials credentials = null);
我找到的唯一示例是基于 newtworkCredentials 的:
https://github.com/object/Simple.OData.Client/blob/master/Simple.OData.Client.IntegrationTests/WebApiTests.cs
public class WebApiWithAuthenticationTests : WebApiTestsBase
{
private const string _user = "tester";
private const string _password = "tester123";
public WebApiWithAuthenticationTests()
: base(new ODataClientSettings()
{
BaseUri = new Uri("http://va-odata-integration.azurewebsites.net/odata/secure"),
Credentials = new NetworkCredential(_user, _password)
})
{
}
}
试试这样使用 CredentialCache.DefaultCredentials
属性。
public class WebApiWithAuthenticationTests : WebApiTestsBase
{
public WebApiWithAuthenticationTests()
: base(new ODataClientSettings()
{
BaseUri = new Uri("http://va-odata-integration.azurewebsites.net/odata/secure"),
Credentials = CredentialCache.DefaultCredentials
})
{
}
}
可以使用简单的 Odata 客户端通过 windows 身份验证来请求我的 Odata 服务(由 Asp.Net MVC 托管)?
简单的 Odata 客户端需要凭据:
public ODataClient(ODataClientSettings settings);
public ODataClientSettings(Uri baseUri, ICredentials credentials = null);
我找到的唯一示例是基于 newtworkCredentials 的: https://github.com/object/Simple.OData.Client/blob/master/Simple.OData.Client.IntegrationTests/WebApiTests.cs
public class WebApiWithAuthenticationTests : WebApiTestsBase
{
private const string _user = "tester";
private const string _password = "tester123";
public WebApiWithAuthenticationTests()
: base(new ODataClientSettings()
{
BaseUri = new Uri("http://va-odata-integration.azurewebsites.net/odata/secure"),
Credentials = new NetworkCredential(_user, _password)
})
{
}
}
试试这样使用 CredentialCache.DefaultCredentials
属性。
public class WebApiWithAuthenticationTests : WebApiTestsBase
{
public WebApiWithAuthenticationTests()
: base(new ODataClientSettings()
{
BaseUri = new Uri("http://va-odata-integration.azurewebsites.net/odata/secure"),
Credentials = CredentialCache.DefaultCredentials
})
{
}
}