繁体   English   中英

AWS Comprehend - NotAuthorizedException

[英]AWS Comprehend - NotAuthorizedException

我是aws的新手。 我想将 api 与 python 结合使用。

我写了以下 python 脚本:

import boto3
import json

comprehend = boto3.client(service_name='comprehend')
                
text = "It is raining today in Seattle"

print('Calling DetectSentiment')
sentiment_output=comprehend.detect_sentiment(Text=text, LanguageCode='en')
print('End of DetectSentiment\n')

我创建了一个具有管理员访问权限的 IAM 用户,并在我的 linux 控制台中对其进行了配置:

(base) florian@florian3090:~/Desktop/aws$ aws configure
AWS Access Key ID [****************BIP6]:
AWS Secret Access Key [****************a/1f]:
Default region name [us-west-1]:
Default output format [json]:

但是每次调用我的python文件都会报错:

botocore.exceptions.ClientError: An error occurred (NotAuthorizedException) when calling the DetectSentiment operation: Your account is not authorized to make this call.

不幸的是,直到现在我都无法解决这个错误。

这是我的第一个 AWS 项目。 我需要解锁什么吗? 我真的很感激任何提示如何解决这个问题。

提前致谢!

请确保您正在使用的 IAM 用户/角色具有访问操作comprehend:DetectSentiment例如,查看附加到您正在使用其凭据的用户的 IAM 策略。 该政策应该包含这样的东西 -

{
   "Version": "2012-10-17",
   "Statement": [{
      "Sid": "AllowSentimentDetect",
      "Effect": "Allow",
      "Action": [
                "comprehend:DetectSentiment"
             ],   
      "Resource": "*"
      }
   ]
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM