Hi. I am new with AWS services and I am trying to use Textract via python. I made the download of following python script from AWS template:
import boto3
from trp import Document
Document
documentName = R'E:\fotos\aaa.jpg'
print (documentName)
boto3.setup_default_session(profile_name='default')
secretsmanager = boto3.client('secretsmanager')
Amazon Textract client
textract = boto3.client('textract')
Call Amazon Textract
with open(documentName, "rb") as document:
response = textract.analyze_document(
Document={
'Bytes': document.read(),
},
FeatureTypes=["TABLES"])
#print(response)
doc = Document(response)
for page in doc.pages:
# Print tables
for table in page.tables:
for r, row in enumerate(table.rows):
for c, cell in enumerate(row.cells):
print("Table[{}][{}] = {}".format(r, c, cell.text))
I created a lot of king of users: portal and IAM user, with or without MFA nor Alias.
Of course all of them using AWS configure to create a credentials file (evey time delete the file first).
When I run the script, every time i got: when calling the AnalyzeDocument operation: The security token included in the request is invalid.
Finally I decide to create a simple user with id and password without IAM nor MFA for this user.
Run again aws configure with input for Access Key ID e Secret Access Key. The remains parameters I assumed the default: region=us-east-1 e output=json.
As this user does not have MFA, i did not run aws sts.
Even thought I got the error of invalid token.
Can anybody help me on this. I am trying for a month to test Textract and I am in a authorization phase yet. Very frustrating.