Sample Code: C# .net

Rest Authorization Header

To authenticate with the rest API, you will need to set the authorization header:

WebRequest request = (WebRequest)WebRequest.Create(url);
request.ContentType = " application/json;charset=utf-8";
request.Headers["Authorization"] = BuildAuthHeader();

Helper functions for the above code:

private static String BuildAuthHeader(String key,  String pin)
{

        // create seed for hash
        String Seed = Guid.NewGuid().ToString();

        // create hash of apikey, seed and pin
        String Hash = GenerateHash(key + Seed + pin);

        // assemble auth string,  api key is the username,  hash is the password
        String authInfo = key + ":s2/" + Seed + "/" + Hash;
        authInfo = "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));

        return authInfo;
}

private static String GenerateHash(string input)
{
        // Create a new instance of the SHA256CryptoServiceProvider object.
        SHA256 shaHasher = SHA256.Create();

        // Convert the input string to a byte array and compute the hash.
        byte[] data = shaHasher.ComputeHash(Encoding.Default.GetBytes(input));

        // Create a new Stringbuilder to collect the bytes
        // and create a string.
        StringBuilder sBuilder = new StringBuilder();

        // Loop through each byte of the hashed data 
        // and format each one as a hexadecimal string.
        for (int i = 0; i < data.Length; i++)
        {
                sBuilder.Append(data[i].ToString("x2"));
        }

        // Return the hexadecimal string.
        return sBuilder.ToString();
}