Generating the X-SAJ-Signature

To ensure authenticity, Snagajob requires that you generate a signature and provide it within the header of your requests. (X-SAJ-Signature)

The X-SAJ-Signature is generated using composed of six values:

  • requestBody

  • requestVerb

  • requestPath

  • requestQuery

  • apiSecret

  • dateHeader (RFC1123 format)

The following code samples show how you can generate a valid signature:

The output of the values listed in the code samples should return a signature equal to:5hY9zBIziUhrAqfEIfSsQB4HddU=

using System;
using System.Security.Cryptography;
using System.Text;
 
public class Program
{
    public static void Main(string[] args)
    {
        string requestBody = "";
	string requestVerb = "POST";
	string requestPath = "/v1/public-api/validate-authorization";
	string requestQuery = "";
        string apiSecret = "your api secret key";
        string dateHeader = "Mon, 31 Oct 2022 20:23:10 GMT";
 
        string  signature = ComputeSignature($"{requestVerb}{requestPath}?{requestQuery};{requestBody};{dateHeader}", apiSecret);
        if (signature.Equals("5hY9zBIziUhrAqfEIfSsQB4HddU="))
        {
            Console.WriteLine("B64 HMAC SHA1: " + signature);
        }
        else
        {
            Console.WriteLine("invalid value: " + signature);
        }
    }
 
    private static string ComputeSignature(string input, string key)
    {
        byte[] keyBytes = Encoding.UTF8.GetBytes(key);
        using(HMACSHA1 myhmacsha1 = new HMACSHA1(keyBytes))
        {
            byte[] inputBytes = Encoding.UTF8.GetBytes(input);
            byte[] hash = myhmacsha1.ComputeHash(inputBytes);
            return Convert.ToBase64String(hash);
        }
    }
}

Testing your signature

You can use this route to validate your authentication:

Last updated

Was this helpful?