Check API credentials against AWS

Hi,

I’m struggling to perform user authentication from AWS cognito-idp. I’m trying to mimic a web portal’s API for my pool chlorinator and it works if I bypass authentication and just send the access token, which I can pull from the portal via developer console, but that is no good for long term use, so I’m trying to pass my username/password to get the tokens properly.

I’ve tried boto3, but it isn’t asynchronous, and I can’t seem to get aioboto3 to work. An extract is bleow:

        session = aioboto3.Session()
        async with session.client('cognito-idp', region_name='us-east-2') as client:
            try:
                # Make async calls with the client
                response = await client.initiate_auth(
                    ClientId=ClientId,
                    AuthFlow='USER_PASSWORD_AUTH',
                    AuthParameters={
                        'USERNAME': username,
                        'PASSWORD': password
                    }
                )

And I have listed aioboto3 as a requirement in the manifest.

Can anyone point me to an example where an integration implements user authentication against AWS cognito that I can use as an example, as it must have been done before and I’m just waisting my time trying to work this out by myself!

Thanks.