Regina Kang
Regina Kang

Reputation: 151

What should I do to fix "The AWS Access Key Id you provided does not exist in our records" using boto3

I hope to upload text file in aws s3.

import boto3
s3=boto3.client('s3')
s3.upload_file('s3_transfer_file.txt','first-storage-for-practice','s3_script.txt')

Getting this error when running the code above:

An error occurred (InvalidAccessKeyId) when calling the PutObject operation: The AWS Access Key Id you provided does not exist in our records.

What should I do to fix this?

Upvotes: -1

Views: 5693

Answers (2)

jacdDev
jacdDev

Reputation: 196

You need to provide your AWS credentials in order to use the services, take a look at https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html

You can do the following:

 import boto3
 s3=boto3.client('s3', your_AWS_AccesKey, your_AWS_SecretKey)
 s3.upload_file('s3_transfer_file.txt','first-storage-for-practice','s3_script.txt')

Upvotes: 1

Ahmed Abdelazim
Ahmed Abdelazim

Reputation: 741

Example usage

import boto3
boto3.client('s3' , region_name='us-west-2',aws_access_key_id='ACCESS_KEY_ID',aws_secret_access_key='SECRET')
s3.upload_file('s3_transfer_file.txt','first-storage-for-practice','s3_script.txt')

Upvotes: 1

Related Questions