Code Monkey home page Code Monkey logo

twilio-sdk-go's Introduction

Twilio Go SDK

Twilio SDK PkgGoDev Release Go Report Card License

This SDK is designed to allow you to interact with Twilio API's using Golang.

This project is compatible with the following versions of Golang:

Version Supported
1.16.x Yes
1.17.x Yes
1.18.x Yes

โš ๏ธ Disclaimer: This project is not an official Twilio project and is not supported or endorsed by Twilio in any way. It is maintained in my free time.

Getting Started

NOTE: The default branch for this project is called main

Documentation

The code uses go doc style documentation with links to the relevant Twilio API documentation/ guides where appropriate.

Examples

Example code snippets for all of the supported services & resources can be found here

Initialising the Twilio Client

There are many ways to initialise and configure the Twilio Client. See below for examples:

With Credentials

creds, err := credentials.New(credentials.Account{
    Sid:       os.Getenv("TWILIO_ACCOUNT_SID"),
    AuthToken: os.Getenv("TWILIO_AUTH_TOKEN"),
})
if err != nil {
    log.Panicf("%s", err.Error())
}

twilioClient := twilio.NewWithCredentials(creds)

With Session

creds, err := credentials.New(credentials.Account{
    Sid:       os.Getenv("TWILIO_ACCOUNT_SID"),
    AuthToken: os.Getenv("TWILIO_AUTH_TOKEN"),
})
if err != nil {
    log.Panicf("%s", err.Error())
}

twilioClient := twilio.New(session.New(creds))

With Session & Config

The Twilio Client allows the user to supply configuration to alter the default behaviour of the SDK.

The SDK supports the following configuration:

  • BackoffInterval - The time taken in milliseconds between retries
  • DebugEnabled - This logs out the request and response details for each call to the Twilio API
  • Edge - Specify a public edge or private interconnect to connect to Twilio via. See Global Infrastructure - Edge Locations for more information
  • Region - Specify a public region or private interconnect region to connect to Twilio via. See Global Infrastructure - Legacy Regions for more information
  • RetryAttempts - The number of retry attempts before an error is returned

Enabling debug mode

creds, err := credentials.New(credentials.Account{
    Sid:       os.Getenv("TWILIO_ACCOUNT_SID"),
    AuthToken: os.Getenv("TWILIO_AUTH_TOKEN"),
})
if err != nil {
    log.Panicf("%s", err.Error())
}

twilioClient := twilio.New(session.New(creds), &client.Config{
   DebugEnabled: true,
})

Specifying Edge & Region configuration

creds, err := credentials.New(credentials.Account{
    Sid:       os.Getenv("TWILIO_ACCOUNT_SID"),
    AuthToken: os.Getenv("TWILIO_AUTH_TOKEN"),
})
if err != nil {
    log.Panicf("%s", err.Error())
}

twilioClient := twilio.New(session.New(creds), &client.Config{
    Edge:       utils.String("dublin"),
    Region:     utils.String("ie1"),
})

Used By

With Thanks

This project is very heavily inspired and influenced by other open-source projects including:

twilio-sdk-go's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar rjpearson94 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

twilio-sdk-go's Issues

Elastic SIP Trunking

First off, glad to see a great resurrection of Twilio support in go! ๐Ÿ‘

Is your feature request related to a problem

Looking to Terraform our Elastic SIP Trunking infrastructure on Twilio and have followed the dependency chain here.

https://www.twilio.com/docs/sip-trunking/api

Describe the solution you'd like

The ability to CRUD:

  • SIP trunks
  • Origination URIs

Additional context

I'll undertake the work, unless it's already being worked on.

Improve logging around SDK credentials to aid with issue triaging

Is your feature request related to a problem

Currently, the logging around account and API key validation errors is limited to prevent secrets from leaking into the logs however this can make it challenging to triage authentication issues when the error is not returned.

This is even more challenging when you do not have direct access to the Go SDK i.e. in the Twilio Terraform provider https://github.com/RJPearson94/terraform-provider-twilio

Describe the solution you'd like

The ability to get additional contextual error messaging when validation failures occur for account or API key credentials. The solution should at least detail what field or fields have failed the validation check.

An added bonus would be to include masked secrets in the logs with the ability to disable masking with an environment variable or some config

Additional context

This arises from RJPearson94/terraform-provider-twilio#27

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.