twilio / twilio-go

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

Not found client/jwt #118

Closed thdung002 closed 2 years ago

thdung002 commented 2 years ago

Issue Summary

I tried with go get github.com/twilio/twilio-go then tried to use the generate accesstoken like the code below

Code Snippet

package main

import 
(
    "os"
    "github.com/twilio/twilio-go/client/jwt"
)

accountSid := os.Getenv("TWILIO_ACCOUNT_SID")
applicationSid := os.Getenv("TWILIO_TWIML_APP_SID")
apiKey := os.Getenv("TWILIO_API_KEY")
apiSecret := os.Getenv("TWILIO_API_SECRET")
identity := "fake123"

params := jwt.AccessTokenParams{
    AccountSid:    accountSid,
    SigningKeySid: apiKey,
    Secret:        apiSecret,
    Identity:      identity,
}

jwtToken := jwt.CreateAccessToken(params)
voiceGrant := &jwt.VoiceGrant{
    Incoming: jwt.Incoming{Allow: true},
    Outgoing: jwt.Outgoing{
        ApplicationSid:    applicationSid,
        ApplicationParams: "",
    },
}

jwtToken.AddGrant(voiceGrant)
token, err := jwtToken.ToJwt()

Exception/Log

 github.com/twilio/twilio-go/client/jwt: module github.com/twilio/twilio-go/client@latest found (v0.0.0-20210629184628-bf0945b77d96), but does not contain package github.com/twili
o/twilio-go/client/jwt

Technical details: