# Azure HTTP Function - Can't Validate!

**URL:** <https://devforum.zoom.us/t/azure-http-function-cant-validate/88078>\
**Category:** Authentication\
**Created:** [May 9, 2023, 9:21am UTC](https://devforum.zoom.us/t/azure-http-function-cant-validate/88078 "2023-05-09T09:21:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stephen.schuster](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/stephen.schuster/32/48332_2.png) [@stephen.schuster](https://devforum.zoom.us/u/stephen.schuster)\
**Post date:** [May 9, 2023, 9:21am UTC](https://devforum.zoom.us/t/azure-http-function-cant-validate/88078/1 "2023-05-09T09:21:14Z")

</div>

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;
    }

    [FunctionName("ZoomPresenceToSlack")]
    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?

Thanks,  
Stephen

---

<div class="post-metadata">

**Author:** ![stephen.schuster](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/stephen.schuster/32/48332_2.png) [@stephen.schuster](https://devforum.zoom.us/u/stephen.schuster)\
**Post date:** [May 9, 2023, 1:33pm UTC](https://devforum.zoom.us/t/azure-http-function-cant-validate/88078/2 "2023-05-09T13:33:09Z")

</div>

Fixed!

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

---

<div class="post-metadata">

**Author:** ![elisa.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/elisa.zoom/32/47836_2.png) [@elisa.zoom](https://devforum.zoom.us/u/elisa.zoom)\
**Post date:** [May 10, 2023, 8:43pm UTC](https://devforum.zoom.us/t/azure-http-function-cant-validate/88078/3 "2023-05-10T20:43:28Z")

</div>

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