# Zoom SDK demo not working as expected

**URL:** <https://devforum.zoom.us/t/zoom-sdk-demo-not-working-as-expected/105881>\
**Category:** Windows\
**Tags:** video-sdk\
**Created:** [March 16, 2024, 5:26pm UTC](https://devforum.zoom.us/t/zoom-sdk-demo-not-working-as-expected/105881 "2024-03-16T17:26:15Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankushtcoders](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/ankushtcoders/32/57561_2.png) [@ankushtcoders](https://devforum.zoom.us/u/ankushtcoders)\
**Post date:** [March 16, 2024, 5:26pm UTC](https://devforum.zoom.us/t/zoom-sdk-demo-not-working-as-expected/105881/1 "2024-03-16T17:26:16Z")

</div>

We wants to use zoom SDK for our Project, so currently we are doing POC on it, we followed documentation and built an App and downloaded SDK for further poc.  
we are able to generate JWT token but after that our callback function never get invoked.  
we are relatively new in this topic so can you please guide us through it.

```auto
namespace zoom_sdk_demo
{
    public partial class MainWindow : Window
    {
        start_join_meeting start_meeting_wnd = new start_join_meeting();
        public MainWindow()
        {
            InitializeComponent();
        }

        // Callback for authentication return
        public void onAuthenticationReturn(AuthResult ret)
        {
            if (AuthResult.AUTHRET_SUCCESS == ret)
            {
                // Step 3: Join Meeting
                try
                {
                    JoinMeeting();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed to join meeting: " + ex.Message);
                }
            }
            else
            {
                MessageBox.Show("Authentication failed. Please try again.");
                Show(); // Show the main window again if authentication fails
            }
        }

        public void onLoginRet(LOGINSTATUS ret, IAccountInfo pAccountInfo, LOGINFAILREASON reason)
        {
            //todo
        }

        public void onLogout()
        {
            //todo
        }

        private void button_auth_Click(object sender, RoutedEventArgs e)
        {
            // Step 1: Generate JWT Token
            string apiKey = "";
            string apiSecret = "";
            string jwtToken = GenerateJWT(apiKey, apiSecret);

            // Step 2: Authenticate with JWT
            AuthenticateWithJWT(jwtToken);

           // Hide();
        }

        // Step 2: Authenticate with JWT
        private void AuthenticateWithJWT(string jwtToken)
        {
            // Register callbacks
            CZoomSDKeDotNetWrap.Instance.GetAuthServiceWrap().Add_CB_onAuthenticationReturn(onAuthenticationReturn);
            CZoomSDKeDotNetWrap.Instance.GetAuthServiceWrap().Add_CB_onLoginRet(onLoginRet);
            CZoomSDKeDotNetWrap.Instance.GetAuthServiceWrap().Add_CB_onLogout(onLogout);

            // Authenticate with Zoom SDK using the generated JWT token
            AuthContext param = new AuthContext
            {
                jwt_token = jwtToken
            };
            CZoomSDKeDotNetWrap.Instance.GetAuthServiceWrap().SDKAuth(param);
        }

        // Step 1: Generate JWT Token
        private string GenerateJWT(string apiKey, string apiSecret)
        {
            apiSecret = Convert.ToBase64String(Encoding.UTF8.GetBytes(apiSecret));
            var securityKey = new SymmetricSecurityKey(Convert.FromBase64String(apiSecret));
            var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);

            // Calculate expiration time (1 hour from now)
            DateTimeOffset now = DateTimeOffset.UtcNow;
            long exp = now.AddHours(1).ToUnixTimeSeconds();

            // Create claims with dynamic expiration time
            var claims = new[]
            {
        new Claim("appKey", apiKey),
        new Claim("iat", now.ToUnixTimeSeconds().ToString()),
        new Claim("exp", exp.ToString()),
        new Claim("tokenExp", exp.ToString())
    };

            // Create JWT token
            var token = new JwtSecurityToken(
                claims: claims,
                signingCredentials: credentials
            );

            // Write and return JWT token as a string
            return new JwtSecurityTokenHandler().WriteToken(token);
        }

        // Step 3: Join Meeting
        private void JoinMeeting()
        {
            // Replace "meeting_id_to_join" with the actual meeting ID you want to join
            string meetingId = "meeting_id_to_join";

            // Here you would typically call the appropriate Zoom SDK method to join the meeting
            // For now, we'll just show the start meeting window as a placeholder
            start_meeting_wnd.Show();
        }

        void Wnd_Closing(object sender, CancelEventArgs e)
        {
            Application.Current.Shutdown();
        }
    }
}

```

here is the main window code, **onAuthenticationReturn** action never get envoked. and there are no error occurs while debug as well

---

<div class="post-metadata">

**Author:** ![chunsiong.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/chunsiong.zoom/32/35488_2.png) [@chunsiong.zoom](https://devforum.zoom.us/u/chunsiong.zoom)\
**Post date:** [March 18, 2024, 3:51am UTC](https://devforum.zoom.us/t/zoom-sdk-demo-not-working-as-expected/105881/2 "2024-03-18T03:51:28Z")

</div>

@ankushtcoders do you have a sample of the generated token?

---

<div class="post-metadata">

**Author:** ![ankushtcoders](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/ankushtcoders/32/57561_2.png) [@ankushtcoders](https://devforum.zoom.us/u/ankushtcoders)\
**Post date:** [March 18, 2024, 11:07am UTC](https://devforum.zoom.us/t/zoom-sdk-demo-not-working-as-expected/105881/3 "2024-03-18T11:07:34Z")

</div>

Hi @chunsiong.zoom ,

Here is the sample code for generate token. Can you please check and let me know what mistake I’m doing.

```
   private string GenerateJWT(string apiKey, string apiSecret)
       {
apiSecret = Convert.ToBase64String(Encoding.UTF8.GetBytes(apiSecret));
var securityKey = new SymmetricSecurityKey(Convert.FromBase64String(apiSecret));
var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);

DateTimeOffset now = DateTimeOffset.UtcNow;
long exp = now.AddHours(1).ToUnixTimeSeconds();

// Create claims with dynamic expiration time
var claims = new[]
{
    new Claim("appKey", apiKey),
    new Claim("iat", now.ToUnixTimeSeconds().ToString()),
    new Claim("exp", exp.ToString()),
    new Claim("tokenExp", exp.ToString())
};

// Create JWT token
var token = new JwtSecurityToken(
    claims: claims,
    signingCredentials: credentials
);
return new JwtSecurityTokenHandler().WriteToken(token);}

```

---

<div class="post-metadata">

**Author:** ![chunsiong.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/chunsiong.zoom/32/35488_2.png) [@chunsiong.zoom](https://devforum.zoom.us/u/chunsiong.zoom)\
**Post date:** [March 18, 2024, 11:19am UTC](https://devforum.zoom.us/t/zoom-sdk-demo-not-working-as-expected/105881/4 "2024-03-18T11:19:16Z")

</div>

@ankushtcoders sorry do you have the generated token?

---

<div class="post-metadata">

**Author:** ![ankushtcoders](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/ankushtcoders/32/57561_2.png) [@ankushtcoders](https://devforum.zoom.us/u/ankushtcoders)\
**Post date:** [March 18, 2024, 3:21pm UTC](https://devforum.zoom.us/t/zoom-sdk-demo-not-working-as-expected/105881/5 "2024-03-18T15:21:35Z")

</div>

here is a token

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBLZXkiOiJQTXZKUHBfdFFjQ2lySnp3SkhZUUl3IiwiaWF0IjoiMTcxMDc3NTIyNSIsImV4cCI6IjE3MTA3Nzg4MjUiLCJ0b2tlbkV4cCI6IjE3MTA3Nzg4MjUifQ.xXqlZ\_2pJk-pelbsUtsJT4jeEZ3rj2\_9k5ZzE7pgpFU

---

<div class="post-metadata">

**Author:** ![chunsiong.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/chunsiong.zoom/32/35488_2.png) [@chunsiong.zoom](https://devforum.zoom.us/u/chunsiong.zoom)\
**Post date:** [March 19, 2024, 2:27am UTC](https://devforum.zoom.us/t/zoom-sdk-demo-not-working-as-expected/105881/6 "2024-03-19T02:27:11Z")

</div>

@ankushtcoders

the date is invalid, could you make sure it is not enclosed in double quotes?

Are you using Meeting SDK or Video SDK?

---

<div class="post-metadata">

**Author:** ![ankushtcoders](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/ankushtcoders/32/57561_2.png) [@ankushtcoders](https://devforum.zoom.us/u/ankushtcoders)\
**Post date:** [March 19, 2024, 6:03am UTC](https://devforum.zoom.us/t/zoom-sdk-demo-not-working-as-expected/105881/7 "2024-03-19T06:03:55Z")

</div>

I am using **meeting sdk.**

I have tried removing quotes from the token but that’s not accepting in a code while creating it.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/4/d/4dfd31d7a8e52e5b3791f3dc23fa6e05e3901f66.png)

---

<div class="post-metadata">

**Author:** ![chunsiong.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/chunsiong.zoom/32/35488_2.png) [@chunsiong.zoom](https://devforum.zoom.us/u/chunsiong.zoom)\
**Post date:** [March 19, 2024, 6:44am UTC](https://devforum.zoom.us/t/zoom-sdk-demo-not-working-as-expected/105881/8 "2024-03-19T06:44:55Z")

</div>

@ankushtcoders can you remove the toString() for iat, exp and expToken?

---

<div class="post-metadata">

**Author:** ![ankushtcoders](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/ankushtcoders/32/57561_2.png) [@ankushtcoders](https://devforum.zoom.us/u/ankushtcoders)\
**Post date:** [March 19, 2024, 9:24am UTC](https://devforum.zoom.us/t/zoom-sdk-demo-not-working-as-expected/105881/9 "2024-03-19T09:24:36Z")

</div>

**I tried it but it through an error for conversion.**

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/b/d/bd5238ae8cfe94933c824749d113004a58c45ba8.png)

---

<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:** [April 18, 2024, 7:24pm UTC](https://devforum.zoom.us/t/zoom-sdk-demo-not-working-as-expected/105881/10 "2024-04-18T19:24:42Z")

</div>

Closed on April 18, 2024, 7:24pm UTC

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