Zoom SDK demo not working as expected

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.

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

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

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);}

@ankushtcoders sorry do you have the generated token?

here is a token

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBLZXkiOiJQTXZKUHBfdFFjQ2lySnp3SkhZUUl3IiwiaWF0IjoiMTcxMDc3NTIyNSIsImV4cCI6IjE3MTA3Nzg4MjUiLCJ0b2tlbkV4cCI6IjE3MTA3Nzg4MjUifQ.xXqlZ_2pJk-pelbsUtsJT4jeEZ3rj2_9k5ZzE7pgpFU

@ankushtcoders

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

Are you using Meeting SDK or Video SDK?

I am using meeting sdk.

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

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

I tried it but it through an error for conversion.

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