DESCRIPTION

We have built a specific end point to check that your freshly generated key (or previously stored key) will correctly allow access to the API.

If the key is valid, a simple “true” will be returned. 

URL STRUCTURE

https://[hostname]/key/validate

METHOD

POST

HEADERS

**Authorization:**    string Base64       [email]:[key]

RETURNS

Sample response

true

EXAMPLE

     C#

using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Cryptography;

/// <summary>
/// Validate an API key with the server, basic example
/// </summary>
/// <param name="userEmail"></param>
/// <param name="password"></param>
/// <returns>bool</returns>
public static async Task<bool> ValidateAPIKey(string userEmail, string password)
{
  bool isValidated = false;
  string url = "https://[hostname]/key/validate";

  // Auth headers
  MD5 md5Hash = MD5.Create();
  string hashedPassword = Security.GetMd5Hash(md5Hash, password);
  var credentials = Convert.ToBase64String(
          Encoding.ASCII.GetBytes(userEmail + ":" + hashedPassword)
  );

  // Content
  var form = new MultipartFormDataContent();

  using (HttpClient client = new HttpClient())
  {
      client.DefaultRequestHeaders.Accept.Clear();
      client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", credentials);

      // Response
      HttpResponseMessage res = await client.PostAsync(url, form);
      content = await res.Content.ReadAsStringAsync();

      if (content != "true")
      {
          isValidated = true;
      }
  }
  return isValidated;
}