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