use*_*107 0 windows amazon-web-services amazon-ses amazon-iam boto3
我想使用boto3库和用户配置文件访问 Amazon\xe2\x80\x99s SES(简单电子邮件服务)。下面列出了我想要执行的代码,但它不起作用。它给了我一个错误 \xe2\x80\x9cbotocore.exceptions.NoCredentialsError: Unable to locatecredentials\xe2\x80\x9d,我目前可以毫无问题地访问S3服务,所以我知道我的配置文件设置正确,但我不能查找使用配置文件访问 SES 服务的代码。我需要一些指导如何让代码工作。
\n\n不起作用的SES 代码
\n\nimport boto3\n\nsession = boto3.session.Session(profile_name=\'myprofile\')\nclient = boto3.client(\'ses\',\'us-east-1\')\nresponse = client.list_verified_email_addresses()\nRun Code Online (Sandbox Code Playgroud)\n\n当前适用于配置文件的 S3 代码
\n\nimport boto3\n\nsession = boto3.session.Session(profile_name=\'myprofile\')\ns3 = session.resource(\'s3\')\nRun Code Online (Sandbox Code Playgroud)\n\n参考:http ://boto3.readthedocs.org/en/latest/reference/services/ses.html
\n在您的 SES 代码中,您没有使用通过您的配置文件创建的会话。但在 S3 代码中,您使用会话。当您致电时boto3.client(),它对您的个人资料一无所知。尝试这个:
session = boto3.Session(profile_name='myprofile')
client = session.client('ses','us-east-1')
response = client.list_verified_email_addresses()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1098 次 |
| 最近记录: |