You can pass an instance of the HttpClientHandler Class with the credentials to the HttpClient Constructor:
using (var handler = new HttpClientHandler { Credentials = ... })
using (var client = new HttpClient(handler))
{
var result = await client.GetAsync(...);
}
More Related Contents:
- What is the purpose of “return await” in C#?
- Is it possible to await an event instead of another async method?
- Async/await vs BackgroundWorker
- Awaiting multiple Tasks with different results
- What’s the difference between Task.Start/Wait and Async/Await?
- Using ‘async’ in a console application in C# [duplicate]
- Do you have to put Task.Run in a method to make it async?
- Awaiting Asynchronous function inside FormClosing Event
- awaitable Task based queue
- Brief explanation of Async/Await in .Net 4.5
- Await operator can only be used within an Async method [duplicate]
- Is async HttpClient from .Net 4.5 a bad choice for intensive load applications?
- How to ‘await’ raising an EventHandler event
- Task.Yield – real usages?
- What’s the difference between InvokeAsync and BeginInvoke for WPF Dispatcher
- Using async / await with DataReader ? ( without middle buffers!)
- Call asynchronous method in constructor?
- Is Task.Run considered bad practice in an ASP .NET MVC Web Application?
- Synchronously waiting for an async operation, and why does Wait() freeze the program here
- How to run a Task on a custom TaskScheduler using await?
- Pattern for calling WCF service using async/await
- Async network operations never finish
- Async call with await in HttpClient never returns
- Is it possible to run a .NET 4.5 app on XP?
- If my interface must return Task what is the best way to have a no-operation implementation?
- An entry point cannot be marked with the ‘async’ modifier
- Is it possible to “await yield return DoSomethingAsync()”
- How to correctly write Parallel.For with async methods
- Converting async/await to Task.ContinueWith
- Create a completed Task