Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"coroutine object is not subscriptable" error calling get_delegated_s3pars #774

Open
lamorgiac opened this issue Aug 23, 2023 · 3 comments

Comments

@lamorgiac
Copy link

I'm trying to connect to a MinIO S3 compatible storage and to create a session token, with this code:

            fs = S3FileSystem(key='minioadmin', secret='minioadmin',
                              endpoint_url='http://127.0.0.1:9000/')
            ses = fs.connect()
            token = fs.get_delegated_s3pars()

I'm having this error:

Failed to generate temporary token for S3: 'coroutine' object is not subscriptable

The problem seems to be in core.py, in this section:

        async with self.session.create_client("sts") as sts:
            cred = sts.get_session_token(DurationSeconds=exp)["Credentials"]
            return {
                "key": cred["AccessKeyId"],
                "secret": cred["SecretAccessKey"],
                "token": cred["SessionToken"],
                "anon": False,
            }

I can see that get_session_token result is a coroutine (coroutine object AioBaseClient._make_api_call).
Why it's trying to get the "Credentials" key from a coroutine?

Thank you for your work!

@lamorgiac lamorgiac changed the title "coroutine is not invokable" error calling get_delegated_s3pars "coroutine object is not subscriptable" error calling get_delegated_s3pars Aug 23, 2023
@martindurant
Copy link
Member

Can you try with

        async with self.session.create_client("sts") as sts:
            cred = (await sts.get_session_token(DurationSeconds=exp))["Credentials"]
            return {
                "key": cred["AccessKeyId"],
                "secret": cred["SecretAccessKey"],
                "token": cred["SessionToken"],
                "anon": False,
            }

@lamorgiac
Copy link
Author

lamorgiac commented Aug 23, 2023 via email

@martindurant
Copy link
Member

You are most welcome to propose that change to the code as a PR.
I daresay that get_delegated_s3pars is not used much, and since it is not implemented by moto, it is not tested in CI. I am glad you have it working - but getting your credentials right is another matter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants