generateAuthorization method
Generate the authorization for the request.
Implementation
String generateAuthorization(
Map<String, String> headers, String payload, DateTime date) {
final canonicalRequest = generateCanonicalRequest(headers, payload);
final stringToSign = generateStringToSign(canonicalRequest, date, _service);
final secretDate = generateSecretDate(date);
final secretService =
_hmacSha256(secretDate.bytes, convert.utf8.encode(_service));
final secretSigning = generateSecretSigning(secretService.bytes);
// Signature = HexEncode(HMAC_SHA256(SecretSigning, StringToSign))
final signature =
_hmacSha256(secretSigning.bytes, convert.utf8.encode(stringToSign))
.toString();
// Authorization =
// Algorithm + ' ' +
// 'Credential=' + SecretId + '/' + CredentialScope + ', ' +
// 'SignedHeaders=' + SignedHeaders + ', ' +
// 'Signature=' + Signature
final credentialScope = generateCredentialScope(date, _service);
final signedHeaders = generateSignedHeaders(headers);
final paramters = [
'Credential=$secretId/$credentialScope',
'SignedHeaders=$signedHeaders',
'Signature=$signature',
].join(', ');
return '$_algorithm $paramters';
}