DESCRIPTION
To generate a new key, you must send a POST request to “key/new” with a basic authentication header containing the user's email/password combination. You must send the password as an MD5 hash.
URL STRUCTURE
https://[hostname]/key/new
METHOD
POST
HEADERS
**Authorization:**
string Base64 [email]:[md5(password)]
PARAMETERS
Name | Type | Description |
---|---|---|
name | string | User string to reference key (optional) |
RETURNS
Sample response
{
"key": "EG1B954ZWH"
}
EXAMPLE
C#
using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Cryptography;
/// <summary>
/// Request the API key from the server based on user email and password, basic example
/// </summary>
/// <param name="userEmail"></param>
/// <param name="password"></param>
/// <returns>string</returns>
public static async Task<string> RequestAPIKey(string userEmail, string password)
{
string key = null;
string url = "https://[hostname]/key/new";
// 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();
// JSON Serialise
dynamic obj = JsonConvert.DeserializeObject(content);
// Handle response
if (obj.key != null)
{
key = obj.key;
}
}
return key;
}