Код: Выделить всё
The remote server returned an error: (403) FORBIDDEN
Код: Выделить всё
public async Task
GetContextWithCredentialsAsync(string url, string username, string password)
{
try
{
if (url.ToUpper().StartsWith("HTTP://") || url.ToUpper().StartsWith("HTTPS://"))
{
var securePassword = new SecureString();
password.ToCharArray().ToList().ForEach(s => securePassword.AppendChar(s));
var clientContext = new ProjectContext(url)
{
Credentials = new NetworkCredential(username, securePassword)
};
clientContext.Load(clientContext.Projects);
clientContext.ExecuteQuery();
return await System.Threading.Tasks.Task.Factory.StartNew(() => { return clientContext; });
}
}
catch (Exception ex)
{
throw ex;
}
return null;
}
Подробнее здесь: https://stackoverflow.com/questions/784 ... 65-and-get