question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

verifyUserAttribute does not appear to send clientMetadata

See original GitHub issue

Describe the bug While implementing MFA I’m attempting to add a phone number attribute to the user. UpdateUser works fine (though it doesn’t trigger the CustomMessage_UpdateUserAttribute lambda, but that’s not an amplify issue). When I call Auth.verifyUserAttribute(user, 'phone_number', { product: 'myProductName' } the cloudwatch logs show no clientMetadata property in the event.

Error from my backend code:

{code: "UserLambdaValidationException", name: "UserLambdaValidationException", message: "CustomMessage failed with error Unsupport product undefined."}

To Reproduce Steps to reproduce the behavior:

  1. Create a pool with a user that has an unverified phone number, and a CustomMessage trigger
  2. Use the Amplify package to call verifyUserAttribute for that user and pass the third parameter some object;
  3. Check the logs of the CustomMessage trigger and see something like
    "triggerSource": "CustomMessage_VerifyUserAttribute",
    "request": {
        "userAttributes": {
            "sub": "<sub>",
            "email_verified": "true",
            "cognito:user_status": "CONFIRMED",
            "cognito:email_alias": "<email>",
            "phone_number_verified": "false",
            "phone_number": "<phone>",
            "given_name": "Michael",
            "family_name": "Riffle",
            "email": "<email>"
        },
        "codeParameter": "{####}",
        "linkParameter": "{##Click Here##}",
        "usernameParameter": null
    },

Expected behavior The request property should have a clientMetadata property that was passed into the function.

Code Snippet Please provide a code snippet or a link to sample code of the issue you are experiencing to help us reproduce the issue. (Be sure to remove any sensitive data)

  async verifyUserAttribute() {
    try {
      const user = await Auth.currentAuthenticatedUser();
      if (!user) {
        throw new Error('User must be initialized to verify attributes');
      }

      const res = await Auth.verifyUserAttribute(user, 'phone_number', {
        product: process.env.REACT_APP_PRODUCT,
      });
    } catch (err) {
      throw err;
    }
  }

Additional context We’re using lambda triggers from cognito for a bunch of other use-cases and everything is working fine. Our app supports CustomMessage_SignUp CustomMessage_ResendCode CustomMessage_ForgotPassword PostConfirmation_ConfirmSignUp PostAuthentication_Authentication And they all work great. This might be an issue lower down with Cognito itself? But I wanted to check here first.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
mauerbaccommented, Apr 28, 2020

Hi @rifflock - thanks for filling this. I was able to reproduce this error on my end. Let me check-in with the team on how to move forward.

0reactions
github-actions[bot]commented, Oct 21, 2021

This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GetUserAttributeVerificationCode - Amazon Cognito User Pools
When you use the ClientMetadata parameter, remember that Amazon Cognito won't do the following: Store the ClientMetadata value. This data is available only...
Read more >
AuthClass | amplify-js
This was previously used by an authenticated user to get MFAOptions, but no longer returns a meaningful response. Refer to the documentation for...
Read more >
Amplify Auth.signIn() ClientMetadata not sent to Lambda Trigger
Try setting the metadata value using Auth.configure before executing Auth.signIn . On one hand, it doesn't look like the sign-in event is a ......
Read more >
Authentication - Advanced workflows - JavaScript - Amplify Docs
You can alternatively use Auth.federatedSignIn() to get AWS credentials directly from Cognito Federated Identities and not use User Pool federation.
Read more >
get-user-attribute-verification-code - Amazon AWS
Otherwise, Amazon Cognito users who must receive SMS messages might not be ... In * sandbox mode * , you can send messages...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found