Azure HTTP Function - Can't Validate!

So I have done it all. I created a new App as well just to be safe. This is a simply WebHook for Presence. The Azure Function works and the logs verify it is getting hit. I can see the payload and the header.

My code is pretty simple:

//private readonly HttpClient _httpClient;
private static readonly HttpClient _httpClient = new HttpClient();
private const string ZoomSignatureHeaderName = “x-zm-signature”;

    public Functions(HttpClient httpClient)
        // _httpClient = httpClient;

    public async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequest req,
    ILogger log)
        var logger = log;

        foreach (var header in req.Headers)
            logger.LogInformation($"{header.Key} : {string.Join(",", header.Value)}");

        string requestBodyFull = new StreamReader(req.Body).ReadToEnd();
        dynamic data = JsonConvert.DeserializeObject(requestBodyFull);

        string plainToken = data?.payload?.plainToken;
        var sharedSecreta = "BLAHBLAHBLAH";
        byte[] secretBytes = Encoding.UTF8.GetBytes(sharedSecreta);
        byte[] plainTokenBytes = Encoding.UTF8.GetBytes(plainToken);
        byte[] hashBytes;

        using (var hmac = new HMACSHA256(secretBytes))
            hashBytes = hmac.ComputeHash(plainTokenBytes);

        string hashedToken = BitConverter.ToString(hashBytes).Replace("-", string.Empty).ToLower();
        log.LogInformation($"Hashed plainToken: {hashedToken}");

        // Create the response object
        dynamic response = new JObject();
        response.plainToken = plainToken;
        response.encryptedToken = hashedToken;
        string responseJson = JsonConvert.SerializeObject(response);
        log.LogInformation($"Response JSON: {responseJson}");

… and my log output verifies this. I also validated the HASH against a 3rd party website just to make sure the calculations were correct.

No matter what I do it just returns but never validates…

I am assuming I have missed some easy thing here, any ideas?



It seems I was using the older token code and not the secret token. Updated and it is working. Now onto other issues,

Happy to hear that you were able to troubleshoot this issue!
Thanks for sharing your solution with the community!