Using this template helps us debug your issues more effectively
Description
I have the apiKey and secret for a “user-managed OAuth2 app” and the permission “scope meeting:read” “meeting:write” and “user:read”.
With this I can generate a token.
However, for all the following actions I get the HTTP response code: 400
e.g.: java.io.IOException: Server returned HTTP response code: 400 for URL: https://api.zoom.us/v2/users/me
Error
java.io.IOException: Server returned HTTP response code: 400 for URL: https://api.zoom.us/v2/users/me
Which App Type (OAuth / Chatbot / JWT / Webhook)?
OAuth
Which Endpoint/s?
https://api.zoom.us/v2/users/me
How To Reproduce (If applicable)
public static String getZoomUserInfo(String zoomApiKey, String zoomApiSecret) throws OAuthSystemException, OAuthProblemException, IOException {
String getUrl = “https://api.zoom.us/v2/users/me”;
URL url = new URL(getUrl);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod(“GET”);
//con.setRequestProperty(“Content-Type”, “application/json”);
con.setRequestProperty(“Authorization”, "Bearer " + OAuthTools.getZoomOAuthToken(zoomApiKey, zoomApiSecret));
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
in.close();
System.out.println(content.toString());
con.disconnect();
return content.toString();
}
public static final String TOKEN_REQUEST_URL = "https://zoom.us/oauth/token";
public static String getZoomOAuthToken(String clientID, String clientSecret) throws OAuthSystemException, OAuthProblemException {
OAuthClient client = new OAuthClient(new URLConnectionClient());
OAuthClientRequest request =
OAuthClientRequest.tokenLocation(TOKEN_REQUEST_URL)
.setGrantType(GrantType.CLIENT_CREDENTIALS)
.setClientId(clientID)
.setClientSecret(clientSecret)
.buildQueryMessage();
OAuthJSONAccessTokenResponse oAUthResponse = client.accessToken(request, OAuthJSONAccessTokenResponse.class);
if (oAUthResponse != null) {
System.out.println(oAUthResponse.getBody());
}
String token = oAUthResponse.getAccessToken();
return token;
}