3

I can trying to set an authentication value just for testing purposes.
I am not using basic authentication but just a String

VC.Request.Headers.Authorization = new AuthenticationHeaderValue("Secret Password");

It gives me this error that is making me pulling my hair off:

The format of value 'Secret Password' is invalid.

Again I don't want to use basic authentication and I don't know whats wrong, help?

Felipe Oriani
  • 37,948
  • 19
  • 131
  • 194
noobiehacker
  • 1,099
  • 2
  • 12
  • 24

2 Answers2

4

The class is "documented" as:

Represents authentication information in Authorization, ProxyAuthorization, WWW-Authneticate[sic], and Proxy-Authenticate header values.

By calling the constructor with one parameter, you're using "Secret Password" as scheme, which can only contain tokens (i.e. no spaces). See RFC 2617 for specification.

You might want to call the other constructor overload:

new AuthenticationHeaderValue("MySuperAuthScheme", "Secret Password");
Community
  • 1
  • 1
CodeCaster
  • 147,647
  • 23
  • 218
  • 272
-2

I think basic authentication generally uses a username:password syntax, so the client-side code might be pre-validating it to stop you sending "bad" data mistakenly to the server, even though that's what you're intentionally trying to do. Try adding a : and see if that helps.

Martin Costello
  • 9,672
  • 5
  • 60
  • 72