问题 错误:使用Boto python时,“请求中包含的安全令牌无效”


当我在nginx上运行我的django项目时,我收到此错误。我使用dynamodb作为数据库,S3使用S3来提供项目中的静态文件。在localhost上运行时,该项目运行正常。

该项目最初是在另一个ec2实例中托管的,它运行起来就像魅力一样。我从该实例的图像中启动了一个新的ec2实例。而现在它正在抛出这个错误。 事情是,

当我在命令上运行一些测试代码时,连接正常   线。

但是在项目运行时会抛出此错误。

/的JSONResponseError

JSONResponseError: 400 Bad Request
{u'message': u'The security token included in the request is invalid.', u'__type': u'com.amazon.coral.service#UnrecognizedClientException'}
Request Method: POST
Request URL:    http://ec2-54-200-144-115.us-west-2.compute.amazonaws.com/?attempt=1&code=AQBfOzPR4Hlgrpkjz-qXQj8b7OLq6cm1NM_oZf64Wz3EmlX2-VDS6qfZ5V5f0Tmbx4MrLc4SGuJxUHa8drQClz3A1IWMVqUGKLEEW_0ol1RqClI8cZViWreBm5c3HJ-Vp48Xx81a7gvXSjRNJUn-kazXqahDrgsAeLez_8FrXIb_HWHyekhnUmxgkskRGBNzcTtpqASNe3agzG3ZZowCMYi6bDBAdVuODli3ApWQWENSmjLaN5QbZWbGo3ATvJNMAUQjj6VTHCkVS-UWcuh-PtwAAFtUqb8HkLsbFG31KevwPKz6x10ojD45pe03zA1SF_g
Django Version: 1.5
Exception Type: JSONResponseError
Exception Value:    
JSONResponseError: 400 Bad Request
{u'message': u'The security token included in the request is invalid.', u'__type': u'com.amazon.coral.service#UnrecognizedClientException'}
Exception Location: /srv/www/test/local/lib/python2.7/site-packages/boto/dynamodb2/layer1.py in _retry_handler, line 1530
Python Executable:  /srv/www/test/bin/python
Python Version: 2.7.3

无法理解发生了什么。谁能帮我?


9602
2018-01-11 08:56


起源

您是否检查过您是否正确复制了ACCESS和SECRET键的值?有时你可能会混淆两者。 - Guy
是的,我查了一下。问题是,从控制台连接正常,但是当我运行项目时会发生此错误。 - Santosh Ghimire


答案:


您收到此消息,因为您的AWS账户的安全凭证/访问密钥已更改。

再次使用新的访问键,它将工作。

祝一切顺利。


10
2018-01-11 09:27



虽然我已经重新创建了我的访问令牌和秘密并用它更新了应用程序,但仍然会抛出同样的错误。 - Santosh Ghimire
那你为什么把这个标记为答案呢? - Tom Thorogood


你使用的是更新版本的python 2.7吗?由于ssl修复,我遇到了类似的错误。 我这样做是有效的

import ssl
# for fix to python on mac which is newer than the one on linux
ssl._create_default_https_context = ssl._create_unverified_context

0
2018-04-15 21:48





因为这里没有一个解决方案适合我。

在一个平均堆栈上,我不得不像sudo一样运行

sudo forever start startme.js

要么

sudo node startme.js

当我没有使用'sudo'时,我收到了错误:

UnrecognizedClientException: The security token included in the request is invalid.

-1
2017-08-12 20:09



这听起来像您的有效AWS凭证仅在root用户的主文件夹中,而不是您自己的。 - raddevon
OP用boto和python问了一个问题,而不是节点...... - ted-k42