Skip to content

Help required: Cognito callback function signature #710

@chippyash

Description

@chippyash

I'm writing a Cognito pre token generation lambda using bref. The docs at https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-token-generation.html suggest that the callback is called with 2 parameters. If I do that in php e.g.

$callback(null, $event);

then I get an error :

{
    "errorType": "ArgumentCountError",
    "errorMessage": "Too few arguments to function {closure}(), 2 passed in /var/task/vendor/bref/bref/src/Runtime/LambdaRuntime.php on line 109 and exactly 3 expected",
    "stack": [
        "#0 /var/task/vendor/bref/bref/src/Runtime/LambdaRuntime.php(109): {closure}()",
        "#1 /opt/bref/bootstrap.php(38): Bref\\Runtime\\LambdaRuntime->processNextEvent()",
        "#2 {main}"
    ]
}

I also looked at https://aws.amazon.com/blogs/mobile/how-to-use-cognito-pre-token-generators-to-customize-claims-in-id-tokens/ and simply returned the event which leads to the same error being thrown.

Does anyone know what that callback signature should be for PHP as the node/python examples don't translate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions