-
Notifications
You must be signed in to change notification settings - Fork 15
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
presigned urls issued by boto3 don't work #1031
Comments
Freshly installed env $ pip freeze
boto3==1.35.72
botocore==1.35.72
certifi==2024.8.30
charset-normalizer==3.4.0
idna==3.10
jmespath==1.0.1
python-dateutil==2.9.0.post0
requests==2.32.3
s3transfer==0.10.4
six==1.16.0
urllib3==2.2.3 with script import boto3
import requests
session = boto3.Session()
access_key_id = "DBhNx2FVFmLoAUzjJDMzWWV4ECCXygmKQfXPz5JqCAez0nkQ1oTtvWbxD9iuhDfwKPKEUvDUUQQdxuUhbdvrkmdU"
secret_access_key = "3296940caefe413b76688ab8067fcbd19ba08844cf9573659b9cac472ab8f24d"
s3_client = session.client(
service_name="s3",
aws_access_key_id=access_key_id,
aws_secret_access_key=secret_access_key,
endpoint_url=f"http://localhost:19080",
)
url = s3_client.generate_presigned_url(ClientMethod="get_object",
Params={'Bucket': "heh1733115156", 'Key': "m1733115167"}, ExpiresIn=30,
HttpMethod="GET", )
print(url)
resp = requests.get(url)
print(resp.text) gives
Could you please check something like this? Would It be an issue with secrets or maybe some misconfiguration? |
The mystery has been solved.The proper boto3 lib configuration is required. The default example for boto3 generates the next URL:
Meanwhile, the AWS CLI generates a bit different one:
Much longer parameters, because it uses
import boto3
import requests
from botocore.config import Config
session = boto3.Session()
access_key_id = "HxEMaAtRRAdKHF8obnnBVQC5z1vpT8mDTKV2PuNwtfkB05ifRBi1w5qiD8sRYznjGDAtppPdFJmrRBiE5ouPX3Hgq"
secret_access_key = "dec72f51d988606b2a996d64db056399f2bccd975e5de9d99b113d9dc63fb192"
my_config = Config(
signature_version = 'v4',
)
s3_client = session.client(
service_name="s3",
aws_access_key_id=access_key_id,
aws_secret_access_key=secret_access_key,
endpoint_url=f"https://localhost:60893",
config=my_config
)
url = s3_client.generate_presigned_url(ClientMethod="get_object",
Params={'Bucket': "heh1733292366", 'Key': "fileToS32.txt"}, ExpiresIn=30,
HttpMethod="GET", )
print(url)
resp = requests.get(url)
print(resp.text) With this option generated URL is fine:
and perfectly works |
All good, thank you. |
To get the url (an example from docs - https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-presigned-urls.html#presigned-urls):
This is the url that is returned:
But during GET I receive:
With URLs returned by authmate and aws s3 cli everything works as expected.
Can be reproduced by the test here - nspcc-dev/neofs-testcases#896
The text was updated successfully, but these errors were encountered: