为什么没有Amazon S3的认证处理准备好了吗? [英] Why are no Amazon S3 authentication handlers ready?

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

问题描述

我有我的$ AWS_ACCESS_KEY_ID并正确设置$ AWS_SECRET_ACCESS_KEY环境变量,而我运行此code:

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.

看来博托不是从我的环境变量取值。如果我通过在密钥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.

推荐答案

宝途的把你的凭据的环境变量。 我测试过这与V2.0b3并能正常工作。它会给precedence在构造函数中明确指定凭据,但它会拿起凭据的环境变量了。

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:\ TEMP 该文件包含两行:

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

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

定义环境变量的 AWS_CREDENTIAL_FILE 以指向C:\ TEMP \ mycred.txt

Define the environment variable AWS_CREDENTIAL_FILE to point at C:\temp\mycred.txt

C:\>SET AWS_CREDENTIAL_FILE=C:\temp\mycred.txt

现在你code以上片段:

Now your code fragment above:

import boto
conn = boto.connect_s3()

将正常工作。

will work fine.

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

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