Format Your New Topic as Follows:
API Endpoint(s) and/or Zoom API Event(s)
https://api.zoom.us/v2/users/me/meetings
Description
I configured a server-to-server oauth app awith these scopes “meeting:read:admin meeting:write:admin etc” and i am trying to create a meeting.
Error?
each time i try to execute a service in my spingboot project to create a meeting through this POST endpoint
“https://api.zoom.us/v2/users/me/meetings”, i get this error :
401 Unauthorized: “{“code”:124,”message”:”Invalid access token.”}"
I am calling the service only once, not using multiple instances of my project or multiple thread .
Debugging
When debugging, i see that i am retrieving a token, and when i try to use that token and use it in postman instead of continuing the service pocess in the debug mode, i get invalid access token too.
But if i generate the access token using Postman, the token allows me to create the meeting ( even tho im using same credentials)
So the issue is probably in this code ?
private void generateAccessToken() {
//the uri for generating an Access token
URI uri = UriComponentsBuilder
.fromUriString(OAUTH_API_URL)
.queryParam("grant_type", "client_credentials")
.queryParam("account_id", ACCOUNT_ID)
.build()
.toUri();
//Setting basic auth credentials & Media type in header
HttpHeaders headers = new HttpHeaders();
headers.setBasicAuth(CLIENT_ID, CLIENT_SECRET);
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
HttpEntity<?> requestEntity = new HttpEntity<>(headers);
//Calling the endpoint
ResponseEntity<AccessTokenResponse> responseEntity = restTemplate.exchange(
uri,
HttpMethod.POST,
requestEntity,
AccessTokenResponse.class);
if (responseEntity.getStatusCode() == HttpStatus.OK) {
AccessTokenResponse accessTokenResponse = responseEntity.getBody();
if (accessTokenResponse != null) {
this.accessToken = accessTokenResponse.getAccessToken();
this.accessTokenExpiry = LocalDateTime
.now()
.plusSeconds(accessTokenResponse.getExpiresIn());
}
}
}
@Getter
private static class AccessTokenResponse {
@JsonProperty("access_token")
private String accessToken;
@JsonProperty("expires_in")
private int expiresIn;
}