Created
January 29, 2021 15:41
-
-
Save balvinder294/c97dd8904cb0bb86f60448ca0b54c913 to your computer and use it in GitHub Desktop.
Method to get scheduled meeting by meeting id in Java using Zoom Rest Api for Zoom Meetings - https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meeting - By https://tekraze.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get ZoomMeeting by Meeting id | |
* | |
* @param meetingId the id of meetting from Zoom | |
* @return the meetingObjectDTO with meeting details | |
*/ | |
@Override | |
public ZoomMeetingObjectDTO getZoomMeetingById(String meetingId) { | |
log.debug("Request to get single meeting by id {}", meetingId); | |
String getMeetingUrl = "https://api.zoom.us/v2/meetings/" + meetingId; | |
log.debug("Meeting Url {}",getMeetingUrl); | |
RestTemplate restTemplate = new RestTemplate(); | |
HttpHeaders headers = new HttpHeaders(); | |
headers.add("Authorization", "Bearer " + generateZoomJWTTOken()); | |
headers.add("content-type", "application/json"); | |
HttpEntity<?> requestEntity = new HttpEntity<>(headers); | |
ResponseEntity<ZoomMeetingObjectDTO> zoomEntityRes = restTemplate | |
.exchange(getMeetingUrl, HttpMethod.GET, requestEntity, ZoomMeetingObjectDTO.class); | |
if(zoomEntityRes.getStatusCodeValue() == 200) { | |
return zoomEntityRes.getBody(); | |
} else if (zoomEntityRes.getStatusCodeValue() == 404) { | |
throw new InternalServerException("User id or email not found for supplied value"); | |
} | |
return null; | |
} | |
/** | |
* Generate JWT token for Zoom using api credentials | |
* | |
* @return JWT Token String | |
*/ | |
private String generateZoomJWTTOken() { | |
String id = UUID.randomUUID().toString().replace("-", ""); | |
SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256; | |
Date creation = new Date(System.currentTimeMillis()); | |
Date tokenExpiry = new Date(System.currentTimeMillis() + (1000 * 60)); | |
Key key = Keys | |
.hmacShaKeyFor(zoomApiSecret.getBytes()); | |
return Jwts.builder() | |
.setId(id) | |
.setIssuer(zoomApiKey) | |
.setIssuedAt(creation) | |
.setSubject("") | |
.setExpiration(tokenExpiry) | |
.signWith(key, signatureAlgorithm) | |
.compact(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment