# Getting 401 error

**URL:** <https://devforum.zoom.us/t/getting-401-error/53823>\
**Category:** API and Webhooks\
**Created:** [July 8, 2021, 9:43am UTC](https://devforum.zoom.us/t/getting-401-error/53823 "2021-07-08T09:43:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rahulchaudhary.sce](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/rahulchaudhary.sce/32/29006_2.png) [@rahulchaudhary.sce](https://devforum.zoom.us/u/rahulchaudhary.sce)\
**Post date:** [July 8, 2021, 9:43am UTC](https://devforum.zoom.us/t/getting-401-error/53823/1 "2021-07-08T09:43:14Z")

</div>

this code is running fine locally but not in production, showing 401 error

var tokenHandler = new System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler();  
var now = DateTime.UtcNow;  
var apiSecret = “\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*”;  
byte symmetricKey = Encoding.ASCII.GetBytes(apiSecret);

```
        var tokenDescriptor = new SecurityTokenDescriptor
        {
            Issuer = " *****************",
            Expires = now.AddSeconds(300),
            SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(symmetricKey), SecurityAlgorithms.HmacSha256),
        };

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

        var client = new RestClient("https://api.zoom.us/v2/users/rahulchaudhary.sce@gmail.com/meetings");
        var request = new RestRequest(Method.POST);
        request.RequestFormat = DataFormat.Json;
        request.AddJsonBody(new { topic = "Meeting with Rahul", duration = "10", start_time = "2021-04-20T05:00:00", type = "2" });

        request.AddHeader("authorization", String.Format("Bearer {0}", tokenString));
        IRestResponse restResponse = client.Execute(request);
        HttpStatusCode statusCode = restResponse.StatusCode;
        int numericStatusCode = (int)statusCode;
        var jObject = JObject.Parse(restResponse.Content);
```

---

<div class="post-metadata">

**Author:** ![will.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/will.zoom/32/14417_2.png) [@will.zoom](https://devforum.zoom.us/u/will.zoom)\
**Post date:** [July 9, 2021, 4:37pm UTC](https://devforum.zoom.us/t/getting-401-error/53823/2 "2021-07-09T16:37:34Z")

</div>

Hi @rahulchaudhary.sce,

What is the exact 401 error you’re getting? Is this an invalid access token error, or something else?

Let me know when you have a chance—thanks!  
Will

---

<div class="post-metadata">

**Author:** ![rahulchaudhary.sce](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/rahulchaudhary.sce/32/29006_2.png) [@rahulchaudhary.sce](https://devforum.zoom.us/u/rahulchaudhary.sce)\
**Post date:** [July 10, 2021, 1:44pm UTC](https://devforum.zoom.us/t/getting-401-error/53823/3 "2021-07-10T13:44:21Z")

</div>

hello,  
Thanks for your replay sir. Now the problem have been resolved.

---

<div class="post-metadata">

**Author:** ![will.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/will.zoom/32/14417_2.png) [@will.zoom](https://devforum.zoom.us/u/will.zoom)\
**Post date:** [July 11, 2021, 5:28pm UTC](https://devforum.zoom.us/t/getting-401-error/53823/4 "2021-07-11T17:28:59Z")

</div>

Glad to hear it @rahulchaudhary.sce 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [August 11, 2021, 3:29am UTC](https://devforum.zoom.us/t/getting-401-error/53823/5 "2021-08-11T03:29:41Z")

</div>

Closed on August 11, 2021, 3:29am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
