Java 向http for AWS api网关添加令牌

Java 向http for AWS api网关添加令牌,java,amazon-web-services,jwt,token,aws-api-gateway,Java,Amazon Web Services,Jwt,Token,Aws Api Gateway,我正在使用下面的代码创建一个对AmazonAWSAPI网关的http请求,其中包含一个对象(mp3Base64)作为其内容。但是,它需要附加授权令牌。有人能解释一下这是如何做到的,并举例说明吗?任何帮助都将受到感激。谢谢 public String executePost(String targetURL, Mp3Base64 mp3Base64) throws IOException { ObjectMapper mapper = new ObjectMapper(); String mp3

我正在使用下面的代码创建一个对AmazonAWSAPI网关的http请求,其中包含一个对象(mp3Base64)作为其内容。但是,它需要附加授权令牌。有人能解释一下这是如何做到的,并举例说明吗?任何帮助都将受到感激。谢谢

public String executePost(String targetURL, Mp3Base64 mp3Base64) throws IOException {

ObjectMapper mapper = new ObjectMapper();
String mp3Base64Json = mapper.writeValueAsString(mp3Base64);
URL obj = new URL(targetURL);
HttpURLConnection connection = (HttpURLConnection) obj.openConnection();
connection = (HttpURLConnection) obj.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type",
    "application/x-www-form-urlencoded");
connection.setRequestProperty("Content-Length",
Integer.toString(mp3Base64Json.getBytes().length));
connection.setRequestProperty("Content-Language", "en-US");
connection.setUseCaches(false);
connection.setDoOutput(true);

//Send request
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
wr.writeBytes("base64=" + mp3Base64Json);
wr.flush();
wr.close();

//Get Response
int responseCode = connection.getResponseCode();
System.out.println("\nSending 'POST' request to URL : " + targetURL);
System.out.println("Post parameters : base64 =" + mp3Base64Json);
System.out.println("Response Code : " + responseCode);
InputStream is = connection.getInputStream();
BufferedReader in = new BufferedReader(
    new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
     response.append(inputLine);
}
in.close();

//print result
System.out.println(response.toString());
return response.toString();
}

令牌只是请求上的一个标头。。。猜测它只是一个jwt?连接。setRequestProperty(“授权”、“承载令牌”);