@VGR 's comment to not use URLEncoder was completely wrong.
It turns out that the solution is:
String q = URLEncoder.encode("mimeType=\"application/vnd.google-apps.presentation\"", StandardCharsets.UTF_8); String f = URLEncoder.encode("files(id,name,webViewLink)", StandardCharsets.UTF_8);
Then to pass
String uri = "https://www.googleapis.com/drive/v3/files?q=" + q + "&fields=" + f + "&key=mykey"
to
HttpRequest httpreq = HttpRequest.newBuilder().uri(URI.create(uri)).header("Authorization", "Bearer " + result.getString("access_token")).build();
The key is the escaped " (double quotes) around the mimeType:
\"application/vnd.google-apps.presentation\"
and to URL encode all of it as well as the fields value.