# How to create JWT token using REST api in c#

**URL:** <https://devforum.zoom.us/t/how-to-create-jwt-token-using-rest-api-in-c/6620>\
**Category:** API and Webhooks\
**Created:** [November 12, 2019, 11:50am UTC](https://devforum.zoom.us/t/how-to-create-jwt-token-using-rest-api-in-c/6620 "2019-11-12T11:50:01Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![sakosile](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/sakosile/32/7512_2.png) [@sakosile](https://devforum.zoom.us/u/sakosile)\
**Post date:** [June 2, 2020, 1:34am UTC](https://devforum.zoom.us/t/how-to-create-jwt-token-using-rest-api-in-c/6620/13 "2020-06-02T01:34:49Z")

</div>

This is what works for me on .Net Core 3.1.4  
var setting = GetZoomSetting(); //This is where I picked the API Key and API Secret From

```
        var zone = TimeZoneInfo.FindSystemTimeZoneById("W. Central Africa Standard Time");
        var utcNow = DateTime.UtcNow;
        var westNow = TimeZoneInfo.ConvertTimeFromUtc(utcNow, zone);
        string s = null;
        TimeSpan t = westNow.AddMinutes(Convert.ToInt32(5)) - new DateTime(1970, 1, 1);
        int secondsSinceEpoch = (int)t.TotalSeconds;

        TimeSpan secpacific = TimeZoneInfo.ConvertTimeFromUtc(utcNow, zone) - new DateTime(1970, 1, 1);
        int NowsecondsSinceEpoch = (int)secpacific.TotalSeconds;
        var tokenHandler = new JwtSecurityTokenHandler();
        var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(setting.API.APISecret));
        var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
        //Finally create a Token
        var header = new JwtHeader(creds);

        //Zoom Required Payload
        var payload = new JwtPayload
        {
            {"aud",s },
            { "iss", setting.API.APIKey},
            { "exp", secondsSinceEpoch },
            {"iat",NowsecondsSinceEpoch }
        };
        var token = new JwtSecurityToken(header, payload);
        var authtoken = tokenHandler.WriteToken(token);
        return authtoken;
```

---

_[View the full topic](https://devforum.zoom.us/t/how-to-create-jwt-token-using-rest-api-in-c/6620)._
