Using HttpClient, send an Authorization token with no schema

Viewed 5197

Note: This question is similar to this one, but its suggested answer doesn't apply here.

I am trying to access this API, which is looking for a header that looks like this:

Authorization: {token}

Note the absence of any authentication scheme.

I have tried doing:

myHttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("", authToken);

Which resulted in an ArgumentException saying that I can't pass an empty string.

I have also tried both:

myHttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(authToken);

and

myHttpClient.DefaultRequestHeaders.Add("Authorization", authToken);

Both of which result in a FormatException.

There seems to be something forcing me to conform to a standard format for my authorization header, but the service I am trying to access doesn't use that standard format.

2 Answers
Related