twilioclient/capabilities.go
func (c *Capability) GenerateToken(ttl time.Duration) (string, error) {
	c.doBuildIncomingScope()
	c.doBuildOutgoingScope()
	now := time.Now().UTC()
	cc := &customClaim{
		Scope: strings.Join(c.capabilities, " "),
		StandardClaims: &jwt.StandardClaims{
			ExpiresAt: now.Add(ttl).Unix(),
			Issuer:    c.accountSid,
			IssuedAt:  now.Unix(),
		},
	}
	token := jwt.NewWithClaims(jwt.SigningMethodHS256, cc)
	return token.SignedString([]byte(c.authToken))
}
func (c *Capability) GenerateToken(ttl time.Duration) (string, error) {
	c.doBuildIncomingScope()
	c.doBuildOutgoingScope()
	now := time.Now().UTC()
	cc := &customClaim{
		Scope: strings.Join(c.capabilities, " "),
		StandardClaims: &jwt.StandardClaims{
			ExpiresAt: now.Add(ttl).Unix(),
			Issuer:    c.accountSid,
			IssuedAt:  now.Unix(),
		},
	}
	token := jwt.NewWithClaims(jwt.SigningMethodHS256, cc)
	return token.SignedString([]byte(c.authToken))
}
func ( c * Capability ) GenerateToken ( ttl time . Duration ) ( string , error ) { c . doBuildIncomingScope ( ) c . doBuildOutgoingScope ( ) now := time . Now ( ) . UTC ( ) cc := & customClaim { Scope : strings . Join ( c . capabilities , " " ) , StandardClaims : & jwt . StandardClaims { ExpiresAt : now . Add ( ttl ) . Unix ( ) , Issuer : c . accountSid , IssuedAt : now . Unix ( ) , } , } token := jwt . NewWithClaims ( jwt . SigningMethodHS256 , cc ) return token . SignedString ( [ ] byte ( c . authToken ) ) }
// Generate the twilio capability token. Deliver this token to your
// JS/iOS/Android Twilio client.
Generate the twilio capability token . Deliver this token to your JS / iOS / Android Twilio client .