Which boto3 version do you prefer for get session token?
I got error while running the python code, my opinion of this kind error usually because wrong version of boto3 function
Here's the code
import boto3
import os
boto3.setup_default_session(profile_name='default')
MFA_ARN="xxxxxxxxxxxxxx"
Duration=129600 # 36 hours
code = input("Enter the MFA code: " )
output = sts.get_session_token(
SerialNumber=MFA_ARN,
DurationSeconds=Duration,
TokenCode=code
)
Here's the error
Traceback (most recent call last):
File "C:\Users\NabihBawazir\Downloads\Segmentation_Technical\aws-token\aws-token\aws_token.py", line 20, in <module>
output = sts.get_session_token(
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\NabihBawazir\AppData\Local\Programs\Python\Python311\Lib\site-packages\botocore\client.py", line 530, in _api_call
return self._make_api_call(operation_name, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\NabihBawazir\AppData\Local\Programs\Python\Python311\Lib\site-packages\botocore\client.py", line 964, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (InvalidClientTokenId) when calling the GetSessionToken operation: The security token included in the request is invalid
This kind error usually because wrong version of boto3 function