django-s3-sqlite icon indicating copy to clipboard operation
django-s3-sqlite copied to clipboard

The provided token is malformed or otherwise invalid

Open andytwoods opened this issue 4 years ago • 4 comments

Hi there,

i'm getting: botocore.exceptions.ClientError: An error occurred (InvalidToken) when calling the PutObject operation: The provided token is malformed or otherwise invalid. I've been exploring the below (bottom of base.py) but no luck so far. Would you have any insights? Thanks, Andy.

 self.s3.Object(
                self.settings_dict["BUCKET"], self.settings_dict["REMOTE_NAME"],
            ).put(Body=file_bytes, ContentMD5=base64.b64encode(binascii.unhexlify(current_md5)).decode("utf-8"))

andytwoods avatar Apr 22 '20 09:04 andytwoods

I've tried adding region info but no luck either.

        self.s3 = boto3.resource(
            "s3", region_name='eu-west-2', config=botocore.client.Config(signature_version=signature_version),
        )

andytwoods avatar Apr 22 '20 09:04 andytwoods

No progress from me as of yet. I suspect using a dedicated session where you specify region_name will help.

session = boto3.session.Session(aws_access_key_id=settings.AWS_ACCESS_KEY_ID,
                                  aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY,
                                  region_name=settings.S3TOOLS_REGION, )

andytwoods avatar May 20 '20 12:05 andytwoods

@andytwoods Im late to the party. Did you ever find a resolution for this? I'm having the same exact problem.

chupert91 avatar Jun 17 '23 01:06 chupert91

@andytwoods Im late to the party. Did you ever find a resolution for this? I'm having the same exact problem.

Sorry don't think we ended up using this.

andytwoods avatar Jun 17 '23 06:06 andytwoods