如何将system.net . icredential传递给API
本文关键字:API icredential net system | 更新日期: 2023-09-27 17:55:02
首先,使用所述API为身份验证提供凭据:
Webservice.Authenticate.Credential credential = new Webservice.Authenticate.Credential
{
Username = "myUserName",
Password = GetMD5("myPassword"), // See below for a MD5 encoding example method
ApplicationId = new Guid("00000000-0000-0000-0000-000000000000"), //YOUR ID HERE
IdentityId = new Guid("00000000-0000-0000-0000-000000000000") //Default is empty guid (no need to edit this)
};
如果我尝试直接使用凭据作为icredential,如_service.Credentials = credential;
,则会发生以下错误:
不能隐式转换类型auth。system.net.iccredals的凭据。我试图强制转换它,但它不能正常工作。
后来,当调用另一个服务时,我尝试以这种方式利用凭据。但是,我不确定如何通过证书。
TransactionService.TransactionService _service = new TransactionService.TransactionService();
TransactionService.TransactionSearchParameters _params = new TransactionService.TransactionSearchParameters();
_service.Credentials = new NetworkCredential(credential.Username, credential.Password);
System.Net。iccredals是一个集合。
试题:
_service.Credentials.Add("uri:my.uri"
, "authenticationType"
, new NetworkCredential(credential.Username, credential.Password)
);