twilio / twilio-go

A Go package for communicating with the Twilio API.
MIT License
278 stars 40 forks source link

Unable to set otp code length #145

Closed venu-prasanna-tw closed 2 years ago

venu-prasanna-tw commented 2 years ago

Issue Summary

I am using https://github.com/twilio/twilio-go/tree/main/rest/verify/v2 library to send OTP code. But I wanted to change the OTP code length and I don't see any option in CreateMessage that will accept the OtpCode length.

Technical details:

childish-sambino commented 2 years ago

This is not a change that can be made in the library. Please file a support ticket to inquire about adding this feature to the API.

kpritam commented 2 years ago

Hi @childish-sambino , as per the API defined here https://www.twilio.com/docs/verify/api/service#create-a-verification-service, verify service do support CodeLength parameter. I can even see CodeLength option available in verify.V2.CreateServiceParams but none of the public facing API supports this.

childish-sambino commented 2 years ago

@kpritam Ah. I see that code length is available when creating the service but not when creating the message. This param is mentioned in the docs you link and as part of the create service params. What docs do you think are needed?

venu-prasanna-tw commented 2 years ago

@childish-sambino So I am using verify api and I want to set code digit length programmatically. I looked at all the Verify APIs and couldn't not find a way to programmatically set code length

I have the following questions:

  1. Is there a way to set code length programmatically.
  2. Is there any docs that would guide us to set the code length when sending OTP using verify.CreateVerificationParams{} (using verifyV2)?
  3. Is there any docs that would help us in utilising the verify.V2.CreateServiceParams ?
childish-sambino commented 2 years ago
  1. Yes
  2. No, the API does not support this.
  3. No, but here's an example:
    
    import (
    "fmt"
    "github.com/twilio/twilio-go"
    verify "github.com/twilio/twilio-go/rest/verify/v2"
    )

func main() { twilioClient := twilio.NewRestClient()

verifyServiceParams := &verify.CreateServiceParams{}
verifyServiceParams.SetFriendlyName("Service with Code Length 10")
verifyServiceParams.SetCodeLength(10)

resp, err := twilioClient.VerifyV2.CreateService(verifyServiceParams)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(*resp.Sid)
}

}

childish-sambino commented 2 years ago

Closing due to inactivity. Please re-open this issue or open a new GitHub issue if you still need help.