I am following this documentation: https://marketplace.zoom.us/docs/sdk/native-sdks/android/mastering-zoom-sdk/start-join-meeting/api-user/authentication and I successfully got the JWT and tried it on jwt.io to see if the token works and it did.
Now my problem is when I use this JWT to retrieve a Zoom Access Token (ZAK). I get a -1 in the connection.getResponseCode() meaning it will just go to the else statement. I simply just followed the code in the documentation and replaced it with my own variables.
try {
URL zoomTokenEndpoint = new URL("https://api.zoom.us/v2/users/" + userId + "/token?type=zak&access_token=" + jwt);
HttpsURLConnection connection = (HttpsURLConnection) zoomTokenEndpoint.openConnection();
if(connection.getResponseCode() == HttpsURLConnection.HTTP_OK) //I get response code of -1 here
{
InputStream responseBody = connection.getInputStream();
InputStreamReader responseBodyReader = new InputStreamReader(responseBody, "UTF-8");
BufferedReader streamReader = new BufferedReader(responseBodyReader);
StringBuilder responseStrBuilder = new StringBuilder();
//get JSON String
String inputStr;
while((inputStr = streamReader.readLine()) != null)
{
responseStrBuilder.append(inputStr);
}
connection.disconnect();
JSONObject jsonObject = new JSONObject(responseStrBuilder.toString());
return jsonObject.getString("token");
}else {
System.out.println("Error in connection");;
return null;
}
} catch (Exception e) {
e.printStackTrace();
}