Rakesh Alajipur

Rakesh Alajipur

  • NA
  • 75
  • 195.7k

Send MFA token with access key for S3 bucket

Mar 27 2019 8:02 AM
I am trying to add MFA (Multi Factor Authentication) in my application, where i am going to store object in aws S3 bucket. I went through AWS documentation but could not find anything where we can pass MFA tokedn while sending any request to AWS programmatically in C#.
 
Here is my working code snippet without MFA,
 
var awsCredentials = new BasicAWSCredentials(accessKey, secretKey);
_client = new AmazonS3Client(awsCredentials, Amazon.RegionEndpoint.USEast1);
var putRequest = new PutObjectRequest {
BucketName = ConfigurationManager.AppSettings["S3BucketName"],
Key = fileName, FilePath = localFilePath,
ContentType = "image/" + Path.GetExtension(fileName),
CannedACL = S3CannedACL.PublicRead };
var req = JsonConvert.SerializeObject(putRequest);
 
I am expecting to add MFA authentication token to this above code.
Thanks,