The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.

Aperta
#19 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
30/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
aws, java
Ambito
cloud

Direzione di ricerca

Inizia con l’esempio GeneratePreSignedUrl mostrato nell’issue e riproduci l’URL generato per il bucket S3 indicato. Esamina il comportamento di AWS SDK for Java per le richieste presigned e l’autorizzazione, quindi verifica che l’esempio produca un URL accettato da S3 usando il meccanismo di autorizzazione richiesto. Il lavoro è completato quando l’errore segnalato non si verifica più oppure l’esempio documenta chiaramente la configurazione supportata.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Below Sample returns subjected error, using latest version of java sdk

package com.amazonaws.samples;

import java.io.IOException;
import java.net.URL;

import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.HttpMethod;
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest;

public class GeneratePreSignedUrl {
private static String bucketName = "bucketforwso2";
private static String objectKey = "/HTML-CHEAT-SHEET-768x8555.pdf";

public static void main(String[] args) throws IOException {
	@SuppressWarnings("deprecation")
	AmazonS3 s3client = new AmazonS3Client(new ProfileCredentialsProvider());

	try {
		System.out.println("Generating pre-signed URL.");
		java.util.Date expiration = new java.util.Date();
		long milliSeconds = expiration.getTime();
		milliSeconds += 1000 * 60 * 60; // Add 1 hour.
		expiration.setTime(milliSeconds);

		GeneratePresignedUrlRequest generatePresignedUrlRequest = 
			    new GeneratePresignedUrlRequest(bucketName, objectKey);
		generatePresignedUrlRequest.setMethod(HttpMethod.GET); 
		generatePresignedUrlRequest.setExpiration(expiration);

		URL url = s3client.generatePresignedUrl(generatePresignedUrlRequest); 

		System.out.println("Pre-Signed URL = " + url.toString());
	} catch (AmazonServiceException exception) {
		System.out.println("Caught an AmazonServiceException, " +
				"which means your request made it " +
				"to Amazon S3, but was rejected with an error response " +
		"for some reason.");
		System.out.println("Error Message: " + exception.getMessage());
		System.out.println("HTTP  Code: "    + exception.getStatusCode());
		System.out.println("AWS Error Code:" + exception.getErrorCode());
		System.out.println("Error Type:    " + exception.getErrorType());
		System.out.println("Request ID:    " + exception.getRequestId());
	} catch (AmazonClientException ace) {
		System.out.println("Caught an AmazonClientException, " +
				"which means the client encountered " +
				"an internal error while trying to communicate" +
				" with S3, " +
		"such as not being able to access the network.");
		System.out.println("Error Message: " + ace.getMessage());
	}
}

}

Generating pre-signed URL.
Pre-Signed URL = https://bucketforwso2.s3.amazonaws.com/%2FHTML-CHEAT-SHEET-768x8555.pdf?AWSAccessKeyId=AKIAJH5K4ZJ6ZQB2F4XB&Expires=1514962084&Signature=rY7RjDwJkck8ZCEGWUr4lSm%2Bkuw%3D

InvalidRequest The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256. 2947D4830B323D3A 4JK5mlUk/a7oOd6WJT5ol5X0prJY+0buLKr9zhnOcoz0mxAk/oc9A/nWHgIC8lggT11xneCtRLU=
Lingua principale
Java
Stelle
241
Fork
345
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di aws-samples/aws-java-sample

Tutte le issue di aws-samples/aws-java-sample

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.