User123
User123

Reputation: 1

AWS4-HMAC-SHA256 Hashing

I am working on a tiktok uploading bot. I do the same thing already with instagram so I thought I might aswell make another one for tiktok.

The only problem I run into is this key in the request headers I need to send which I can't for the life of me figure out: "Authorization": AWS4-HMAC-SHA256 Credential=*access_key_id/YYYYMMDD/gcp/vod/aws4_request, SignedHeaders=x-amz-date;x-amz-security-token, Signature=signature

I know what to do. I need to generate the AWS4-HMAC-SHA256 signature. I have all the input parameters, except for the region (normally in the place of gcp there would be something along the lines of "us-east-1" but I can't seem to get the right signature. I ran this code with every region available for AWS and the weird region "gcp" (which I read has something to do with google cloud) but the signature never matches. I tried multiple versions of the algorithm I found online (like https://github.com/MiniGlome/Tiktok-uploader/blob/main/Tiktok_uploader.py, which is outdated since on this persons request the "gcp" is replaced by a viable region. I also used the AWS documentation to make the code by myself but the signature also didn't match.

So finally: is there a browser/browser tool which I can use which shows me the inner workings of my browser on how it generates this signature. Because imho there has to be a way since the browser 100% does the signing here. Any help outside of this browser/browser tool is also appreciated

Upvotes: 0

Views: 487

Answers (1)

titusd
titusd

Reputation: 536

I had the same problem with mismatched signatures when calling the API create multipart upload API (https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateMultipartUpload.html).

In that call, the query string is '?uploads'. So it has a query key without a value.

I was using 'uploads' when calculating my signature, while AWS treats it as 'uploads='.

I simply changed the string to '?uploads=1' and the signatures matched.

Upvotes: 0

Related Questions