-
Notifications
You must be signed in to change notification settings - Fork 376
Description
Hi!
I recently implemented a lambda for AWS Cognito integration with the user-pool-lambda-post-confirmation event.
The sdk event for that is this: event/cognito/mod.rs#L87.
Looks like this event is not correct. I think maybe the docs are out of date? The docs page show an empty json for Response (html#cognito-user-pools-lambda-trigger-syntax-post-confirmation).
{ "request": { "userAttributes": {"string": "string",. . .},"clientMetadata": {"string": "string",. . .}},"response": {}}
The CognitoEventUserPoolsPostConfirmationResponse is also an empty object.
We found when logging into the app via socials for the first time (login implemented with Amplify SDK for iOS), an error is thrown and login fails. The error message mentions the lambda
Location:applocation://?error_description=Invalid+version+in+Lambda+response.+Version+should+be+1+&state=e3811fde-b3fe-4507-9992-fa2b228ed194&error=invalid_request
The JS example in the lower part of the docs shows simply returning the input even which contains the version field. After updating the code to return the event user pools header (I saw it had this same version field), it worked.
type EventResponse = CognitoEventUserPoolsHeader<CognitoEventUserPoolsPostConfirmationTriggerSource>;
async fn function_handler(
event: LambdaEvent<CognitoEventUserPoolsPostConfirmation>
) -> Result<EventResponse> {
let payload = event.payload;
let event_response = payload.cognito_event_user_pools_header;
.... // details
Ok(event_response)
}