def admin_initiate_auth()

in src/services/clients/cognito.py [0:0]


    def admin_initiate_auth(self, username: str, password: str
                            ) -> AuthenticationResult | None:
        """
        Initiates the authentication flow. Returns AuthenticationResult if
        the caller does not need to pass another challenge. If the caller
        does need to pass another challenge before it gets tokens,
        ChallengeName, ChallengeParameters, and Session are returned.
        """
        try:
            r = self.client.admin_initiate_auth(
                UserPoolId=self.user_pool_id,
                ClientId=self.client_id,
                AuthFlow='ADMIN_NO_SRP_AUTH',
                AuthParameters={
                    'USERNAME': username,
                    'PASSWORD': password
                }
            )
            return {
                'id_token': r['AuthenticationResult']['IdToken'],
                'refresh_token': r['AuthenticationResult'].get('RefreshToken'),
                'expires_in': r['AuthenticationResult']['ExpiresIn']
            }
        except self.client.exceptions.UserNotFoundException:
            return
        except self.client.exceptions.NotAuthorizedException:
            return