0

I am trying to work with Authy verification; however, I am not able to work with it. I am currently using Parse Server with CloudCode to work with it, here is a snapshot of the code :

Parse.Cloud.define("SendSMS", async (request) => {
  client.verify.services.create({
      friendlyName: 'verificationService'
    })
    .then(service => {
      console.log('service 1 ', service);
    }, err => {
      console.error('err ', err);
    });
});

The problem is that Twilio's API throws :

{ [Error: Too many requests]
  status: 429,
  message: 'Too many requests',
  code: 20429,
  moreInfo: 'https://www.twilio.com/docs/errors/20429',
  detail: undefined }

By the way, when trying to send SMS it works without any issues "using client.sendSms()" the issue is only related with "client.verify.services.create()"

Hamza L.
  • 1,783
  • 4
  • 25
  • 47
  • Have you looked at the [url](https://www.twilio.com/docs/errors/20429) within the error message? It seems that you are calling this function and therefore calling Twilio's api too many times. – Davi Macêdo Aug 08 '19 at 16:39
  • @DaviMacêdo already looked at that, but as you can see from the cloud function, it's called only once. I am trying to apply the following: https://www.twilio.com/docs/verify/api/verification not sure if it's the right way to implement it using Cloud code or the code should be written differently. – Hamza L. Aug 08 '19 at 18:08
  • 1
    You can do it through cloud code and the way you are writing the cloud code seems right. But I see that the way you are using the Twilio api is different in comparison to the link you sent. Why don't you try just like the example in the link? – Davi Macêdo Aug 09 '19 at 15:58
  • @DaviMacêdo thanks for debugging with me, it turns that the error came from Twilio, after contacting them everything worked fine. – Hamza L. Aug 10 '19 at 23:20
  • Nice! I'm glad to know. – Davi Macêdo Aug 12 '19 at 04:06

1 Answers1

0

you may want to put an await clause before the first function.

 await client.verify.services.create({