3

want to send android app hash along with the otp with the help of twillio but not getting proper tutorails in rails. i tried in this way

require 'twilio-ruby'
@client = Twilio::REST::Client.new("XXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXX")
verification = @client.verify.services('VXXXXXXXXXXXXXXXXX').verifications.create(app_hash: "HXXXXXXX", to: '+91XXXXXXXXX', channel: 'sms')

But getting againg and again error unknown keyword: app_hash

I followed this tutorial https://www.twilio.com/docs/verify/api/verification

anothermh
  • 9,815
  • 3
  • 33
  • 52
Khushboo
  • 31
  • 1
  • Please provide an example from the documentation that tells you to use `create(app_hash: ...)` because the example code on the linked page does not show that. – anothermh Jul 18 '20 at 17:54
  • That is the problem. There is no example for same. In the docs all the parameters are just mentioned. Just like 'locale', 'channel_configuration', 'app_hash' e.t.c. – Khushboo Jul 18 '20 at 18:09

2 Answers2

1

Your app's hash string is the first 11 characters of the base64-encoded hash. Try to pass 11 characters: Ex: 'He42w354ol9'.

verification = @client.verify
  .services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .verifications
  .create(to: '+15017122661', channel:'sms', app_hash:'He42w354ol9')

Source: https://developers.google.com/identity/sms-retriever/verify#computing_your_apps_hash_string

ewertoncodes
  • 468
  • 3
  • 11
  • I was trying to do it in same manner. But everytime I am receiving unknown keyword error. But when i don't use 'app_hash' key. It works perfectly fine. – Khushboo Jul 19 '20 at 10:49
  • Wha the version of gem? Use the last version. – ewertoncodes Jul 19 '20 at 10:52
  • any other option to do same functionality with another gem ? – Khushboo Jul 19 '20 at 11:13
  • I have this error: Twilio::REST::RestError ([HTTP 400] 60200 : Unable to create record Invalid parameter: AppHashI https://www.twilio.com/docs/errors/60200. When my app_hash dont have a value with 11 chars. – ewertoncodes Jul 19 '20 at 11:33
-2

The Twilio Ruby API excerpt goes like:

@client = Twilio::REST::Client.new(account_sid, auth_token)

verification = @client.verify
                      .services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                      .verifications
                      .create(to: '+15017122661', channel: 'sms')

I don't see any app_hash parameter, where did you get that from? Try removing it and see what's going on.

Nick M
  • 2,424
  • 5
  • 34
  • 57
  • 1
    In the docs https://www.twilio.com/docs/verify/api/verification?code-sample=code-start-a-verification-with-sms&code-language=Ruby&code-sdk-version=5.x all the parameters are just mentioned. Just like 'locale', 'channel_configuration', 'app_hash', 'custom_code' e.t.c. – Khushboo Jul 18 '20 at 18:31
  • and in this github article, it is also mentioned https://github.com/TwilioDevEd/sms-verification-android-ruby/blob/master/sms_verify.rb – Khushboo Jul 18 '20 at 18:35
  • looks like its an initializer parameter...can you try without it and see what happens – Nick M Jul 18 '20 at 18:51
  • This is not an answer and does not attempt to answer the question. It is a question itself and should be posted as a comment, not an answer. – anothermh Jul 18 '20 at 19:23
  • Knushboo so were you trying to get it to work, or just trying to figure out why it wouldn’t work as you were trying in the first place? – Nick M Jul 19 '20 at 06:07
  • I am trying to figure out that why it is not working. According to doc and github article this should work. And I also need to implement it is in my verification function as well. – Khushboo Jul 19 '20 at 10:47
  • Alright then, sorry about that, thought you just wanted to get it to work. – Nick M Jul 19 '20 at 20:23