Webinar Registration through Java

Webinar Registration through Java

New development for calling zoom webinar from Java code
On clicking the link the user will be directed to Zoom webinar for registration along with name and email address

Please let me know the end point(URL) and the parameters need to be passed

POST/Webinars/{webinarid}/registrants

Hey @raju.jan86,

Did you have a question? I don’t understand.

Thanks,
Tommy

Hi Tommy

Requirement : From my Application I need to call webinar(zoom) with the user details, so that the user will register for the webinar which has been already created.

Example Webinar URL : https://api.zoom.us/v2/webinars/123456789/registrants/

Step 1: I need to get access tone from zoom
Step 2: I need to call webinar URL using the access token

I had tried below code for getting access token from Zoom

I am getting below response

Response Body : {“reason”:“Invalid request : Redirect URI mismatch.”,“error”:“invalid_request”}

What should be the fix for the above error

public void getAccessToken() {

String authorization = (client_id +":"+client_secret).toString();
String authBase64String = Base64.getEncoder().encodeToString(authorization.getBytes());

RequestBody formBody = new FormBody.Builder()
		.add("grant_type","authorization_code")
		.add("code", "obBEe8ewaL_KdYKjnimT4KPd8KKdQt9FQ") //code copied from google
		.add("redirect_uri", webinarURL)
		.build();
		
Request request = new Request.Builder()
		.url(access_url)
		.addHeader("Authorization", "Basic "+authBase64String)
		.post(formBody)
		.build();

try {
	
	Response response = httpClient.newCall(request).execute();

	System.out.println("Response Body : "+response.body().string());
	
} catch (Exception e) {
	System.out.println("getAccessToken Exception : "+e);
}

}

Hey @raju.jan86,

For the Redirect URI mismatch make sure you have your redirect url in your whitelist in the app marketplace settings.

Also your redirect url is not your webinarURL, it is the redirect url set in your app marketplace:

Thanks,
Tommy

Hi Team,

Below is the code I have written to connect zoom registrants API.

First getAccessToken() method will be called.

Then sendPOST() method will be called.

Could you please check whether the below logic is fine for connecting.

I am getting Socket Timeout Exception on this.

public class TestMain {

public static void main(String[] args) {
	TestMain test = new TestMain();
	test.getAccessToken();
	test.sendPOST();
}

private void getAccessToken() {
	System.out.println("getAccessToken Starts");
		
	String client_id = "123456789123456789";

	String client_secret = "987654321987654321";
	
	String authCode = "obBEe8ewaL_KdYKjnimT4KPd8KKdQt9FQ"; //code copied from google
	
    String authorization = (client_id +":"+client_secret).toString();
	
    String authBase64String = Base64.getEncoder().encodeToString(authorization.getBytes());
    
	String access_url = "https://zoom.us/v2/oauth/token";
	
	OkHttpClient httpClient = new OkHttpClient();
	
    RequestBody formBody = new FormBody.Builder()
    		.add("grant_type","authorization_code")
    		.add("code", authCode)
    		.add("redirect_uri", webinarURL)
    		.build();
    
	String oAthuToken2 = access_url+"?grant_type=authorization_code&code="+authCode+"&redirect_uri="+webinarURL;
	
    Request request = new Request.Builder()
            .url(oAthuToken2)
            .addHeader("Authorization", "Basic "+authBase64String)
            .post(formBody)
            .build();

    try {
    	
    	Response response = httpClient.newCall(request).execute();
    	
    	System.out.println("Response : " + response);
    	
    	if(response.isSuccessful()) {
    		System.out.println("**************Successfull***************");
    	}
    	
        System.out.println("Response Body : "+response.body().string());
        
    } catch (Exception e) {
    	System.out.println("getAccessToken Exception : "+e);
    }
    System.out.println("getAccessToken Ends");
}

private void sendPOST()  {

	String webinarURL = "https://api.zoom.us/v2/webinars/123456778/registrants"; 
		
    RequestBody formBody = new FormBody.Builder()
    		.add("email","sjfkghdsg@someemail.dfgjd")
    		.add("first_name","Jill")
    		.add("last_name","Chill")
            .build();

    Request request = new Request.Builder()
            .url(webinarURL)
            .addHeader("User-Agent", "OkHttp Bot")
            .post(formBody)
            .build();

    try {
    	Response response = httpClient.newCall(request).execute();
    	
    	System.out.println("Response : " + response);
    	if(response.isSuccessful()) {
    		System.out.println("**************Successfull***************");
    	}
        System.out.println(response.body().string());
    } catch (Exception e) {
    	System.out.println("Exception : "+e);
    }
}

}

Hey @raju.jan86,

Are you getting any error messages from Zoom? Have you tried googling the Socket Timeout Exception error?

Thanks,
Tommy