Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/xaviiic/twiliogo

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/xaviiic/twiliogo

  • v0.0.0-20180710073304-36d848581bc2
  • Source
  • Go
  • Socket score

Version published
Created
Source

TwilioGo

A Golang library for twilio server side SDK.

Installation

Install the package with go:

go get github.com/xaviiic/twilioGo

Import the package to your go file:

import (
    twilio "github.com/xaviiic/twilioGo"
)

Usage

Access Token

Access Tokens are short-lived tokens that you can use to authenticate Twilio Client SDKs like Video and IP Messaging. You create them on your server to verify a client's identity and grant access to client API features.

To create an access token, pass the Twilio API account information first.

// first create token with twilio api configurations
token := twilio.NewAccessToken(accountID, keyID, secret)
// setup token identity
token.SetIdentity(identity)

Once you have created a token instance, you can add access grant with desired API features.

// grant token access to progammable video API
grant := twilio.NewConversationGrant(configurationProfileID)
token.AddGrant(grant)

// grant token access to video API
grant := twiliogo.NewVideoGrant(room)
token.AddGrant(grant)

Then transform token to JWT format for client side usages.

jwt, err := token.ToJWT()

Capability Token

Capability tokens allow you to add Twilio capabilities to web and mobile applications without exposing your AuthToken in JavaScript or any other client-side environment.

Create a capability token instance first with API account information.

capability := twilio.NewCapability(accountID, authToken)

Then setup the capabilities of token and output a JWT format token.

// allow incoming connections
capability.AllowClientIncoming(clientName)
// allow outgoing connections
capability.AllowClientOutgoing(appID, nil)
jwt, err := capability.ToJWT()

Chaining

Generating token steps can be chained together.

token, err := twilio.NewAccessToken(accountSid, apiKey, apiSecret).
    SetIdentity(identity).
    AddGrant(twilio.NewConversationGrant(configurationSid)).
    SetTTL(30 * time.Minute).
    ToJWT()

License

Copyright 2016 xaviiic

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

FAQs

Package last updated on 10 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc