I want to retrieve the bearer token for application only authorization in C#. The API Documentation tells me to put 'Basic ’ into the Authorization header, so I wrote this code:
string authHeadVal = "Basic " + base64BearerTokenCreds;
httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(authHeadVal);
But when I run my application I get an error message:
An exception of type ‘System.FormatException’ occurred in mscorlib.dll but was not handled in user code
Additional information: The format of value ‘Basic c2lWbUgz9ZWVpUWXlla1MwdDow5mc2JkOExRaTN1l6Q2FjUEpqSm91NhZVlyVA==’ is invalid.
(I replaced some characters with *, because it’s a ‘password’ :))
Does someone know how to do this?