I have setup an account on GoDaddy and have my developer keys for accessing the API. Using Fiddler I am able to construct a request that returns results. However, using the following code from a Console application fails with "Unauthorized". I'm using the same address and keys in both places.
What am I missing?
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Authorization", "sso-key VUjHMntw_UyosKRMGaLXE4e3E1h29Xx:DSqM2jiJcRyXvSbLehjYUZ");
HttpResponseMessage response = await client.GetAsync("https://api.ote-godaddy.com/v1/domains/available?domain=google.com");
if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadAsAsync<string>();
Console.WriteLine(result);
}
else
{
Console.WriteLine(response.ReasonPhrase);
}
}
NOTE: The authorization key and secret have been modified.
The following is what I do in Fiddler that works:
I'm fairly certain you're sending the auth header as:
Authorization: Authorization sso-key VUjHMntw_UyosKRMGaLXE4e3E1h29Xx:DSqM2jiJcRyXvSbLehjYUZ
Try this instead:
client.DefaultRequestHeaders.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue("sso-key", "VUjHMntw_UyosKRMGaLXE4e3E1h29Xx:DSqM2jiJcRyXvSbLehjYUZ");
The Authorization:
prefix is assigned for you by the method call.