HttpClient
is just a wrapper around an HTTP request. Authentication in HTTP requests generally involves sending a POST request to an auth endpoint and getting back some data. That data is then attached to subsequent HTTP requests, generally as an HTTP header. There are already well-defined authentication systems defined for HTTP that you should use. Please do not invent your own.
For basic authentication you attach the data as part of the HTTP request's Authorization
header with a type of Basic. For C# that can be done by attaching a BasicAuthenticationHeaderValue
with the username and password specified as parameters. That header then encodes everything.
For an API key-style authentication where a specific key must be passed in the header you would just add the HTTP header to the request along with the value.
There are libraries already provided that can do this for you automatically but it depends on what version of .NET you're using. I would recommend that you look at the version you're using to see if there are already extensions for it.