Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trying to generate signature to chime, returning InvalidSignatureException #20

Open
durvalpereira opened this issue Apr 3, 2021 · 1 comment

Comments

@durvalpereira
Copy link

below my code from function created.

public String generateSignature(String currentDate) throws URISyntaxException {
        String contentSha256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
        URI uri = new URI("https://service.chime.aws.amazon.com");
        HttpRequest request = new HttpRequest("GET", uri);
        String signature = Signer.builder()
                .awsCredentials(new AwsCredentials(ACCESS_KEY, SECRET_KEY))
                .header("Host", "service.chime.aws.amazon.com")
                .header("x-amz-date", currentDate)
                .header("x-amz-content-sha256", contentSha256)
                .build(request, "chime", contentSha256)
                .getSignature();

        return signature;
    }

stil returning

<InvalidSignatureException>
  <Message>The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.</Message>
</InvalidSignatureException>

can you help me out? this lib is the closer thing i got from solving this issue of connecting at AWS/Chime Rest API.

@benynagy
Copy link

Hi Durval,
I only tested this library against S3 API (worked for me), however, what you put there looks correct at first glance.
The suspect could be the currentDate as you provide it in the parameter, make sure it has format like this, e.g.: "20150830T123600Z".
The "Host" is probably correct as it is, just a small remark - as I had distinct port to use, so I had to put hostname:port into that header in order to make it work, but that should not be your case.
Last but not least, try to validate the AWS credentials - easy to do e.g. in Postman tool (if you haven't tried already) - you can select AWS Signature on Authorization tab, set your credentials and see the auto-generated signature, which gets into Authorization header in the request, and try to test calling the API from the tool at first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants