即使用户拥有所有权限,AWS 机械土耳其人请求错误

问题描述

我正在使用 boto3 创建 HIT 类型的 HIT,但收到此请求错误

err An error occurred (RequestError) when calling the CreateHITWithHITType operation: This user is not authorized to perform the requested operation. (1618759537161 s)

奇怪的是,根据 IAM 的说法,我使用密钥的用户拥有 mtruk 操作的所有必要权限 - 完全访问权限。

当我尝试使用 mturk API 获取帐户余额或创建没有类型的 HIT 时,一切正常。

更有趣的是,当我使用没有权限用户时,我会收到不同的错误

botocore.exceptions.ClientError: An error occurred (AccessDeniedException) when calling the GetAccountBalance operation: User: arn:aws:iam::SOME_USER is not authorized to perform: mechanicalturk:CreateHITWithHITType with an explicit deny

这个错误看起来像是一个正确的权限错误,在 IAM 中这个其他用户没有正确的权限。

那么我遇到的第一个错误是什么意思?

代码如下:

import boto3

client = boto3.client(
    'mturk',endpoint_url='https://mturk-requester-sandBox.us-east-1.amazonaws.com',region_name='us-east-1',aws_access_key_id='SOME_KEY1',aws_secret_access_key='SOME_KEY2',)

kwargs = {'HITTypeId': 'REAL_TYPE1','MaxAssignments': 10,'LifetimeInSeconds': 172800,'HITLayoutId': 'REAL_TYPE2','HITLayoutParameters': [{'Name': 'question_id','Value': '1'},{'Name': 'video_url1','Value': ''},{'Name': 'video_url2','Value': 'VALID_URL'}],'Requesterannotation': 'some_Metadata','AssignmentReviewPolicy': {'PolicyName': 'REAL_POLICY','Parameters': [{'Key': 'AnswerKey','MapEntries': [{'Key': '6','Values': ['a']},{'Key': '7','Values': ['b']}]},{'Key': 'RejectIfKNownAnswerscoreIsLessthan','Values': ['2']},{'Key': 'RejectReason','Values': ['You did not answered correctly']}]}}
# response1 = client.get_account_balance() - this WORKS
# print('response1 ',response1)
try:
  response2 = client.create_hit_with_hit_type(**kwargs) # this FAILS - prints error
except Exception as e:
  print('err',e)

有谁知道这个错误的根源是什么以及我如何解决它? 谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)