# Error: The Token's Signature resulted invalid when verified using the Algorithm: HmacSHA256

**URL:** <https://devforum.zoom.us/t/error-the-tokens-signature-resulted-invalid-when-verified-using-the-algorithm-hmacsha256/12601>\
**Category:** API and Webhooks\
**Created:** [April 10, 2020, 6:06pm UTC](https://devforum.zoom.us/t/error-the-tokens-signature-resulted-invalid-when-verified-using-the-algorithm-hmacsha256/12601 "2020-04-10T18:06:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![justin\_holton](https://avatars.discourse-cdn.com/v4/letter/j/35a633/32.png) [@justin\_holton](https://devforum.zoom.us/u/justin_holton)\
**Post date:** [April 10, 2020, 6:07pm UTC](https://devforum.zoom.us/t/error-the-tokens-signature-resulted-invalid-when-verified-using-the-algorithm-hmacsha256/12601/1 "2020-04-10T18:07:00Z")

</div>

I’m trying to authenticate with the Zoom API using C# and a [JWT.io](http://JWT.io) library (System.IdentityModel.Tokens.Jwt). When I use the token generated in the App Marketplace under JWT \> App Credentials I can retrieve info from [https://api.zoom.us/v2/users](https://api.zoom.us/v2/users), so I know my request to the API is fine. The problem I’m having is with generating a valid token. I’ve verified multiple times that my API Key and API Secret are both correct and are being passed into the correct variables.

Here is my C# code for generating the token. Am I missing something? My header and payload look fine, and I’ve tried both SecurityAlgorithms.HmacSha256Signature and SecurityAlgorithms.HmacSha256 to no avail.

```
protected static string GenerateJSONWebToken()
    {
        var symmetricKey = Convert.FromBase64String(ApiSecret);
        var tokenHandler = new JwtSecurityTokenHandler();
        tokenHandler.SetDefaultTimesOnTokenCreation = false;

        var now = DateTime.UtcNow;
        var tokenDescriptor = new SecurityTokenDescriptor
        {
            Issuer = ApiKey,
            Expires = now.AddSeconds(30),
            SigningCredentials = new SigningCredentials(
                new SymmetricSecurityKey(symmetricKey),
                SecurityAlgorithms.HmacSha256Signature),
        };

        var stoken = tokenHandler.CreateToken(tokenDescriptor);
        var token = tokenHandler.WriteToken(stoken);

        return token;
    }
```

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [April 11, 2020, 7:11am UTC](https://devforum.zoom.us/t/error-the-tokens-signature-resulted-invalid-when-verified-using-the-algorithm-hmacsha256/12601/2 "2020-04-11T07:11:39Z")

</div>

Hey @justin_holton,

Have you tried googling the error? Checkout this stackoverflow:

> <https://stackoverflow.com/questions/38725038/c-how-to-verify-signature-on-jwt-token>

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![justin\_holton](https://avatars.discourse-cdn.com/v4/letter/j/35a633/32.png) [@justin\_holton](https://devforum.zoom.us/u/justin_holton)\
**Post date:** [April 13, 2020, 5:25am UTC](https://devforum.zoom.us/t/error-the-tokens-signature-resulted-invalid-when-verified-using-the-algorithm-hmacsha256/12601/3 "2020-04-13T05:25:20Z")

</div>

Of course. I googled for hours. I’ve since figured out the issue was the Convert.FromBase64String() function. Rather than converting from base 64 I simply converted the “API Secret” as a normal string and that did the trick. If anyone is using C# and needs a function to generate your JWT, I can confirm this code works for me.

```
protected static string GenerateJSONWebToken()

```

{  
var symmetricKey = Encoding.ASCII.GetBytes(ApiSecret);  
var tokenHandler = new JwtSecurityTokenHandler();

```
var now = DateTime.UtcNow;
var tokenDescriptor = new SecurityTokenDescriptor
{
	Issuer = ApiKey,
	Expires = now.AddSeconds(10),
	SigningCredentials = new SigningCredentials(
		new SymmetricSecurityKey(symmetricKey),
		SecurityAlgorithms.HmacSha256Signature),
};

var stoken = tokenHandler.CreateToken(tokenDescriptor);
var token = tokenHandler.WriteToken(stoken);

return token;

```

}

It would have been nice if Zoom provided this code in [their JWT documentation](https://marketplace.zoom.us/docs/guides/auth/jwt) under “Sample Code.” The sample code provided instead is just a generic API call with no indication on how to generate the JWT. For that I had to google. Don’t get me wrong, Zoom’s sample code _is_ useful but it would have been a lot more useful if the JWT section actually had JWT sample code.

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [April 13, 2020, 10:25pm UTC](https://devforum.zoom.us/t/error-the-tokens-signature-resulted-invalid-when-verified-using-the-algorithm-hmacsha256/12601/4 "2020-04-13T22:25:00Z")

</div>

Hey @justin_holton,

Glad you figured out the issue! We will add JWT Token creation examples to our docs! 🙂

CC @shrijana.g

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![shrijana.g](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/shrijana.g/32/605_2.png) [@shrijana.g](https://devforum.zoom.us/u/shrijana.g)\
**Post date:** [April 15, 2020, 12:03am UTC](https://devforum.zoom.us/t/error-the-tokens-signature-resulted-invalid-when-verified-using-the-algorithm-hmacsha256/12601/5 "2020-04-15T00:03:23Z")

</div>

Thank you @justin_holton for making us aware of this. We will add this request to our backlog and ensure that the JWT creation step is clearly explained in our docs.

---

<div class="post-metadata">

**Author:** ![acandela](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@acandela](https://devforum.zoom.us/u/acandela)\
**Post date:** [April 16, 2020, 6:58pm UTC](https://devforum.zoom.us/t/error-the-tokens-signature-resulted-invalid-when-verified-using-the-algorithm-hmacsha256/12601/6 "2020-04-16T18:58:39Z")

</div>

Hi, i have the same issue, but i’m using postman with the request for get a user, i used the credentials in **View JWT Token** , the expiration date is for tomorrow

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [April 17, 2020, 7:51pm UTC](https://devforum.zoom.us/t/error-the-tokens-signature-resulted-invalid-when-verified-using-the-algorithm-hmacsha256/12601/7 "2020-04-17T19:51:56Z")

</div>

Hey @acandela,

Can you try regenerating your JWT Secret Key and trying again?

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![DeveloperBot](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/developerbot/32/12632_2.png) [@DeveloperBot](https://devforum.zoom.us/u/DeveloperBot)\
**Post date:** [August 21, 2020, 8:27pm UTC](https://devforum.zoom.us/t/error-the-tokens-signature-resulted-invalid-when-verified-using-the-algorithm-hmacsha256/12601/8 "2020-08-21T20:27:12Z")

</div>

Closed on August 21, 2020, 8:27pm UTC


