Próbuję uzyskać dostęp do prostego usługi AWS IOT REST, ale nie udało mi się jeszcze pomyślnie. Oto co zrobiłem.AWS IOT - poświadczenie powinno mieć zasięg do poprawnej usługi
- stworzyłem IAM użytkownikowi w moich AWS i pobrać klucz dostępu i tajny klucz
- zalogowany do AWS IOT z użytkownikiem i stworzył „coś”
- z nieruchomości stwora znalazłem REST URL w cieniu
- Używane Listonosz z nowym „aws podpisu” cecha, dając mu klucza dostępu, klucz tajny, region (us-wschód-1) i nazwy usługi (IOT)
próbował „GET” punkt końcowy i to jest to, co mam -
{ "message": "Credential should be scoped to correct service. ", "traceId": "be056198-d202-455f-ab85-805defd1260d" }
Myślałem, że jest coś nie tak z listonoszem więc próbowałem przy użyciu przykład AWS-SDK-próba podłączenia do S3 i zmienił go połączyć się z adresem URL IOT. Oto mój program fragment (Java)
String awsAccessKey = "fasfasfasdfsdafs"; String awsSecretKey = "asdfasdfasfasdfasdfasdf/asdfsdafsd/fsdafasdf"; URL endpointUrl = null; String regionName = "us-east-1"; try { endpointUrl = new URL("https://dasfsdfasdf.iot.us-east-1.amazonaws.com/things/SOMETHING/shadow"); }catch (Exception e){ e.printStackTrace(); } Map<String, String> headers = new HashMap<String, String>(); headers.put("x-amz-content-sha256", AWSSignerBase.EMPTY_BODY_SHA256); AWSSignerForAuthorizationHeader signer = new AWSSignerForAuthorizationHeader( endpointUrl, "GET", "iot", regionName); String authorization = signer.computeSignature(headers, null, // no query parameters AWSSignerBase.EMPTY_BODY_SHA256, awsAccessKey, awsSecretKey); // place the computed signature into a formatted 'Authorization' header // and call S3 headers.put("Authorization", authorization); String response = HttpUtils.invokeHttpRequest(endpointUrl, "GET", headers, null); System.out.println("--------- Response content ---------"); System.out.println(response); System.out.println("------------------------------------");
To daje mi ten sam błąd -
--------- Request headers ---------
x-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
Authorization: AWS4-HMAC-SHA256 Credential=fasfasfasdfsdafs/20160212/us-east-1/iot/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=3b2194051a8dde8fe617219c78c2a79b77ec92338028e9e917a74e8307f4e914
x-amz-date: 20160212T182525Z
Host: dasfsdfasdf.iot.us-east-1.amazonaws.com
--------- Response content ---------
{"message":"Credential should be scoped to correct service. ","traceId":"cd3e0d96-82fa-4da5-a4e1-b736af6c5e34"}
------------------------------------
Czy ktoś może mi powiedzieć co robię źle proszę? Dokumentacja AWS nie zawiera wielu informacji na temat tego błędu. Pomóż w tym celu:
Czy rozwiązałeś problem? Jestem z tym samym –
ten sam problem tutaj – MeV