我可以匿名使用 boto3 吗? [英] Can I use boto3 anonymously?

查看:21
本文介绍了我可以匿名使用 boto3 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 boto,我可以通过传递 anon= 关键字参数,无需凭据即可连接到公共 S3 存储桶.

With boto I could connect to public S3 buckets without credentials by passing the anon= keyword argument.

s3 = boto.connect_s3(anon=True)

这可以用 boto3 实现吗?

推荐答案

是的.您的凭据用于对您发出的所有请求进行签名,因此您需要做的是将客户端配置为根本不执行签名步骤.你可以这样做:

Yes. Your credentials are used to sign all the requests you send out, so what you have to do is configure the client to not perform the signing step at all. You can do that as follows:

import boto3
from botocore import UNSIGNED
from botocore.client import Config

s3 = boto3.client('s3', config=Config(signature_version=UNSIGNED))
# Use the client

这篇关于我可以匿名使用 boto3 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆