# Generate Authentication Token from C# server - fail when trying to use this generated C# signature on client.join()

**URL:** <https://devforum.zoom.us/t/generate-authentication-token-from-c-server-fail-when-trying-to-use-this-generated-c-signature-on-client-join/48472>\
**Category:** Web\
**Created:** [April 21, 2021, 7:09am UTC](https://devforum.zoom.us/t/generate-authentication-token-from-c-server-fail-when-trying-to-use-this-generated-c-signature-on-client-join/48472 "2021-04-21T07:09:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![joecodingjourney\_1](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@joecodingjourney\_1](https://devforum.zoom.us/u/joecodingjourney_1)\
**Post date:** [April 21, 2021, 7:09am UTC](https://devforum.zoom.us/t/generate-authentication-token-from-c-server-fail-when-trying-to-use-this-generated-c-signature-on-client-join/48472/1 "2021-04-21T07:09:49Z")

</div>

I am trying to generate an authentication token from C# that I can pass into the client side.

I have tried couple ways to generate the auth token using C#. Can you please let me know what’s wrong the following snippet C# codes?

PART I

```auto
    var signature = string.Empty;

                var iat = Math.Round(GetTime() / 1000);
                var exp = iat + 7200;

                var claims = new List<Claim>
                {
                    new Claim("app_key", zoomInfo.SdkKey),
                    new Claim("iat", iat.ToString(CultureInfo.InvariantCulture)),
                    new Claim("exp", exp.ToString(CultureInfo.InvariantCulture)),
                    new Claim("tpc", topic),
                    new Claim("pwd", string.Empty)
                };

                var key = zoomInfo.SdkSecret;
                var encoding = new ASCIIEncoding();
                byte[] keyByte = encoding.GetBytes(key);
                var securityKey = new SymmetricSecurityKey(keyByte);
                var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);

                var secToken = new JwtSecurityToken(
                    zoomInfo.SdkKey,
                    null,
                    claims,
                    DateTime.UtcNow,
                    DateTime.UtcNow.AddHours(10),
                    credentials);

                var handler = new JwtSecurityTokenHandler();
                signature = handler.WriteToken(secToken);

```

PART II =\> THIS WILL CREATE CORS ISSUE

```auto
    var key = zoomInfo.SdkSecret;
                var encoding = new ASCIIEncoding();
                byte[] keyByte = encoding.GetBytes(key);
                var securityKey = new SymmetricSecurityKey(keyByte);
                var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256Signature);
                var now = DateTime.UtcNow;
                var tokenDescriptor = new SecurityTokenDescriptor
                {
                    Issuer = zoomInfo.SdkKey,
                    Expires = now.AddHours(1),
                    SigningCredentials = credentials,
                    Claims = new Dictionary<string, object>
                    {
                        {"app_key", zoomInfo.SdkKey},
                        {"iat", iat.ToString(CultureInfo.InvariantCulture)},
                        {"exp", exp.ToString(CultureInfo.InvariantCulture)},
                        {"tpc", topic},
                        {"pwd", string.Empty}
                    }
                };

                var handler = new JwtSecurityTokenHandler();
                var token = handler.CreateJwtSecurityToken(tokenDescriptor);
                signature = handler.WriteToken(token);

```

I need to get that signature so that I can pass the signature into the following

```auto
client.join(
  topic,
  signature,
  userName,
  password,
).then(() => {
  console.log('Join meeting success');
}).catch((error) => {
  console.error(error);
});

```

Thanks

---

<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 22, 2021, 11:43pm UTC](https://devforum.zoom.us/t/generate-authentication-token-from-c-server-fail-when-trying-to-use-this-generated-c-signature-on-client-join/48472/2 "2021-04-22T23:43:24Z")

</div>

Hey @joecodingjourney_1 ,

What is the error message you are getting? Also, if you got this code snippet from our docs, can you please share the link so we can investigate?

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![joecodingjourney\_1](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@joecodingjourney\_1](https://devforum.zoom.us/u/joecodingjourney_1)\
**Post date:** [April 23, 2021, 7:50am UTC](https://devforum.zoom.us/t/generate-authentication-token-from-c-server-fail-when-trying-to-use-this-generated-c-signature-on-client-join/48472/3 "2021-04-23T07:50:38Z")

</div>

Hi Tommy, I figured that authentication stuff.

However I got another question about rendering the canvas whenever there are participant join the meeting.

So, if we have multiple participants trying to join the meeting, do we need to create multiple canvas for the video rendering?

Or, all of those participants can share a canvas?

Thanks,  
-Joseph

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [April 23, 2021, 1:14pm UTC](https://devforum.zoom.us/t/generate-authentication-token-from-c-server-fail-when-trying-to-use-this-generated-c-signature-on-client-join/48472/4 "2021-04-23T13:14:51Z")

</div>

Hey @joecodingjourney_1 ,  
You can render multiple videos in one canvas, use `width`, `height`, `x`, and `y` parameters of `renderVideo` method to specify the position of video in the canvas.

Thanks  
Vic

---

<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:** [May 23, 2021, 11:15pm UTC](https://devforum.zoom.us/t/generate-authentication-token-from-c-server-fail-when-trying-to-use-this-generated-c-signature-on-client-join/48472/5 "2021-05-23T23:15:25Z")

</div>

Closed on May 23, 2021, 11:15pm UTC

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