Server returned HTTP response code: 401. Rest implementation in java

I tried to implement Zoom Rest service in java but I am getting some error like this:

 

java.io.IOException: Server returned HTTP response code: 401 for URL: https://api.zoom.us/v2/users?access_token=gySP1M3XWcg4uPBMvhTesy1zTHVOW7tX7jBN
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at com.example.Zoom.ZoomDev.main(ZoomDev.java:21)

 

 

 

@Aadarsh, should include correct JWT token in the API request.

Used this as well:

conn.setRequestProperty(“Authorization”, “Bearer <TOKEN ID>”);

I am getting the same response in my java code as well.
Any solution?

Hey @baljit.karwal,

Can you share the full request you’re making that’s returning the 401?

Please ensure you’re using the correct API Key and Secret to generate your JWToken as well—as this is the most common reason for this error.

Best,
Will

2 Likes

Let me try the solution you gave in another post @will.zoom.

It worked when I passed “iss” as “api_key” in my claims to JWT.
Below simple JWT create worked to create valid token using “https://github.com/auth0/java-jwt”:
JWT.create().withClaim(“iss”, apiKey).withClaim(“exp”, tokenExpiryTimestamp).sign(algorithm);

Thanks
Baljit

2 Likes

Thanks for following up here with the solution, @baljit.karwal!

Best,
Will

1 Like