I am working with the AWS Transcribe streaming service that boto3 does not support yet, so to make HTTP/2 requests, I need to manually setup the authorization header with the "AWS Signature Version 4"

I've found some example implementation, but I was hoping to just call whatever function boto3/botocore have implemented using the same configuration object.

Something like

 session = boto3.Session(...) auth = session.generate_signature('POST', '/stream-transcription', ...) 

Any pointers in that direction?

3 Answers

Did you check this SDK? Seems very recent but might do what you need.

It looks like it handles the signing:

1

Contrary to the AWS SDKs for most other programming languages, boto3/botocore don't offer the functionality to sign arbitrary requests using "AWS Signature Version 4" yet. However there is at least already an open feature request for that:

In this feature request, existing alternatives are discussed as well. One is the third-party Python library aws-requests-auth, which provides a thin wrapper around botocore and requests to sign HTTP-requests. That looks like the following:

import requests from aws_requests_auth.boto_utils import BotoAWSRequestsAuth auth = BotoAWSRequestsAuth(aws_host="your-service.domain.tld", aws_region="us-east-1", aws_service="execute-api") response = requests.get("", auth=auth) 

Another alternative presented in the feature request is to implement the necessary glue-code on your own, as shown in the following gist: .

I have not tested this, but you can likely accomplish this by following along with with this SigV4 unit test:

Note, this constructs a request using the botocore.awsrequest.AWSRequest helper. You'll likely need to dig around to figure out how to send the actual HTTP request (perhaps with httpsession.py)

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy