Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing required parameter error when updating factor in verify.v2 #1019

Closed
yifanplanet opened this issue Apr 29, 2024 · 4 comments
Closed

Comments

@yifanplanet
Copy link

yifanplanet commented Apr 29, 2024

Issue Summary

I received error RestException [Error]: Missing required parameter FriendlyName in the post body when using wilio-node SDK and verifying factor using update method following the doc: Verify that the user has successfully registered

Steps to Reproduce

  1. Create the factor
  2. Try to verify the factor by calling update with the totp code

Code Snippet

const client = twilio(accountSid, authToken);
const factor = await client.verify.v2
  .services(twilioServiceId)
  .entities(userPublicId)
  .factors(factorSid)
  .update({
    authPayload: totpCode,
  });

Exception/Log

RestException [Error]: Missing required parameter FriendlyName in the post body

Technical details:

  • twilio-node version: 5.0.4
  • node version:18.7.0
@tiwarishubham635
Copy link
Contributor

It works correctly for me though. Can you re-check once?

@tiwarishubham635
Copy link
Contributor

Just to be on the same page, I followed these steps:

  1. I created a service from here and stored the Service SID in variable serviceSid
  2. Next, I created an entity using this code snippet:
const identity = 'user-identity';
client.verify.v2.services(serviceSid)
             .entities
             .create({
                 identity: identity
             })
             .then(entity => console.log(entity));
  1. Then I created a new TOTP factor using this:
client.verify.v2.services(serviceSid)
    .entities(identity)
    .newFactors
    .create({
        friendlyName: `Name`,
        factorType: 'totp'
    })
    .then(new_factor => console.log(new_factor));
  1. I saved the value of new_factor.sid in factorSid and used new_factor.binding.uri to create QR code using this.
  2. Scanned this QR code and saved the key in my phone.
  3. Then used the following code snippet for verification:
const totpCode = '123456'
client.verify.v2.services(serviceSid)
    .entities(identity)
    .factors(factorSid)
    .update({authPayload: totpCode})
    .then(factor => console.log(factor));
  1. The status shows verified for me

Let me know if I am doing something different but it works fine for me. Thanks!

@yifanplanet
Copy link
Author

Sorry that was a mistake on my side. Thanks so much for detailed steps for the implementation.
One question: Is the entity create step necessary for the factor verification?

@tiwarishubham635
Copy link
Contributor

Nope, it is not necessary. I just created it to see if that os creating a problem for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants