为什么没有准备好 Amazon S3 身份验证处理程序? [英] Why are no Amazon S3 authentication handlers ready?

查看:27
本文介绍了为什么没有准备好 Amazon S3 身份验证处理程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正确设置了 $AWS_ACCESS_KEY_ID 和 $AWS_SECRET_ACCESS_KEY 环境变量,然后运行以下代码:

I have my $AWS_ACCESS_KEY_ID and $AWS_SECRET_ACCESS_KEY environment variables set properly, and I run this code:

import boto
conn = boto.connect_s3()

并得到这个错误:

boto.exception.NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers were checked. ['HmacAuthV1Handler']

发生了什么事?我不知道从哪里开始调试.

What's happening? I don't know where to start debugging.

似乎 boto 没有从我的环境变量中获取值.如果我将密钥 ID 和秘密密钥作为参数传递给连接构造函数,这将正常工作.

It seems boto isn't taking the values from my environment variables. If I pass in the key id and secret key as arguments to the connection constructor, this works fine.

推荐答案

Boto 从环境变量中获取您的凭据.我已经用 V2.0b3 测试过它,它工作正常.它将优先考虑在构造函数中明确指定的凭据,但也会从环境变量中获取凭据.

Boto will take your credentials from the environment variables. I've tested this with V2.0b3 and it works fine. It will give precedence to credentials specified explicitly in the constructor, but it will pick up credentials from the environment variables too.

最简单的方法是将您的凭据放入一个文本文件中,并指定该文件在环境中的位置.

The simplest way to do this is to put your credentials into a text file, and specify the location of that file in the environment.

例如(在 Windows 上:我希望它在 Linux 上也能正常工作,但我没有亲自尝试过)

For example (on Windows: I expect it will work just the same on Linux but I have not personally tried that)

创建一个名为mycred.txt"的文件并将其放入C: emp该文件包含两行:

Create a file called "mycred.txt" and put it into C: emp This file contains two lines:

AWSAccessKeyId=<your access id>
AWSSecretKey=<your secret key>

定义环境变量 AWS_CREDENTIAL_FILE 指向 C: empmycred.txt

Define the environment variable AWS_CREDENTIAL_FILE to point at C: empmycred.txt

C:>SET AWS_CREDENTIAL_FILE=C:	empmycred.txt

现在你上面的代码片段:

Now your code fragment above:

import boto
conn = boto.connect_s3()

会正常工作.

这篇关于为什么没有准备好 Amazon S3 身份验证处理程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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