sigv4 2.1.0+2 sigv4: ^2.1.0+2 copied to clipboard
Library for signing AWS requests with Signature Version 4, with both convenience wrappers/classes and cryptography methods
sigv4 #
A Dart library for signing AWS requests with Signature Version 4.
Usage #
Create a Sigv4Client
. This will hold your secrets and configuration. Some omitted default values:
region
defaults toeu-west-1
serviceName
defaults toexecute-api
final client = Sigv4Client(
accessKey: 'your_access_key',
secretKey: 'your_secret_key',
);
The easier way to create a request is by getting a package:http
request object:
// A simple GET-request
final request = client.request('https://service.aws.com/endpoint');
get(request.url, headers: request.headers);
// A larger request
final request = client.request(
'https://service.aws.com/endpoint',
method: 'POST',
queryParameters: {'key': 'value'},
headers: {'header': 'value'},
body: {'content': 'some-content'},
);
post(request.url, headers: request.headers, body: request.body);
Alternatively, you can get the canonical string and signed headers separately:
final path = 'https://service.aws.com/endpoint';
final queryParameters = {'key': 'value'};
final url = client.canonicalUrl(path, queryParameters: queryParameters);
final headers = client.signedHeaders(
path,
queryParameters: queryParameters,
);
get(url, headers: headers);