Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

798
Views
El flujo USER_PASSWORD_AUTH de autenticación de AWS Cognito no está habilitado para este cliente

Tengo una aplicación móvil con grupo de usuarios (nombre de usuario y contraseña). La aplicación funciona bien con aws-amplify sdk. Pero quería trasladar el código a Lambdas. Entonces, he escrito el siguiente Lambda usando Boto3.

Aquí está Lambda:

 import boto3 def lambda_handler(event, context): client = boto3.client('cognito-idp') response = client.initiate_auth( ClientId='xxxxxxxxxxxxxx', AuthFlow='USER_PASSWORD_AUTH', AuthParameters={ 'USERNAME': 'xxxxxx', 'PASSWORD': 'xxxxxx' } ) return response

Probé admin_initiate_auth también.

 import boto3 def lambda_handler(event, context): client = boto3.client('cognito-idp') response = client.initiate_auth( UserPoolId='xxxxxxxxx', ClientId='xxxxxxxxxxxxxx', AuthFlow='USER_PASSWORD_AUTH', AuthParameters={ 'USERNAME': 'xxxxxx', 'PASSWORD': 'xxxxxx' } ) return response

Aquí está el error que obtengo.

Se produjo un error (InvalidParameterException) al llamar a la operación InitiateAuth: USER_PASSWORD_AUTH flujo no habilitado para este cliente: InvalidParameterException Rastreo (última llamada más reciente):
Archivo "/var/task/lambda_function.py", línea 12, en lambda_handler 'PASSWORD': 'xxxxx' Archivo "/var/runtime/botocore/client.py", línea 317, en _api_call return self._make_api_call(operation_name, kwargs) Archivo "/var/runtime/botocore/client.py", línea 615, en _make_api_call raise error_class(parsed_response, operation_name) InvalidParameterException: Se produjo un error (InvalidParameterException) al llamar a la operación InitiateAuth: flujo USER_PASSWORD_AUTH no habilitado para este cliente

¿Alguna idea?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Lo imaginé. Tengo que ir al grupo de usuarios -> clientes de aplicaciones -> mostrar detalles -> Habilitar el flujo de nombre de usuario y contraseña (no SRP) para la autenticación basada en la aplicación (USER_PASSWORD_AUTH).

Eso lo arregló.

over 4 years ago · Santiago Trujillo Report

0

Lo imaginé. Tengo que ir al grupo de usuarios -> clientes de aplicaciones -> mostrar detalles -> Habilitar la autenticación de contraseña de nombre de usuario para las API de administración para la autenticación (ALLOW_ADMIN_USER_PASSWORD_AUTH).

over 4 years ago · Santiago Trujillo Report

0

Para mí encontré que mis credenciales necesitaban un hmac aquí está la clase en caso de que sea útil para alguien.

 import boto3 import boto3.session import hmac, base64, hashlib from botocore.client import ClientMeta class AwsAuth(object): ''' classdocs ''' def gettoken(self): if self.token: return self.token else: return False def connect(self): if not self.username: self.username = raw_input("Username: ") if not self.password: self.password = raw_input("Password: ") digest = self.gethmacdigest(self.username) response = self.client.initiate_auth( ClientId=self.clientid, AuthFlow='USER_PASSWORD_AUTH', AuthParameters={ 'USERNAME': self.username, 'PASSWORD': self.password, 'SECRET_HASH': digest }, ClientMetadata={ 'UserPoolId': self.userpoolid } ) self.token = response return response def gethmacdigest(self, username): message = username + self.clientid dig = hmac.new(self.clientsecret, msg=message.encode('UTF-8'), digestmod=hashlib.sha256).digest() return base64.b64encode(dig).decode() def __init__(self, path, url, fileout, filein, userpoolid, clientid, clientsecret, region, username = None, password = None): ''' Constructor ''' #boto3.set_stream_logger('botocore', level="DEBUG") self.path = path self.url = url self.fileout = fileout self.filein = filein self.userpoolid = userpoolid self.clientid = clientid self.clientsecret = clientsecret self.region = region self.token = "" boto3.setup_default_session(region_name=region) self.client = boto3.client('cognito-idp') if username is not None: self.username = username else: self.username = None if password is not None: self.password = password else: self.password = None
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!