package ingress
import (
"time"
"github.com/livekit/protocol/auth"
"github.com/livekit/protocol/livekit"
)
func BuildIngressToken(apiKey, secret, roomName, participantIdentity, participantName, participantMetadata, ingressID string) (string, error) {
f := false
t := true
grant := &auth.VideoGrant{
RoomJoin: true,
Room: roomName,
CanSubscribe: &f,
CanPublish: &t,
CanUpdateOwnMetadata: &t,
}
at := auth.NewAccessToken(apiKey, secret).
SetVideoGrant(grant).
SetIdentity(participantIdentity).
SetName(participantName).
SetKind(livekit.ParticipantInfo_INGRESS).
SetValidFor(24 * time.Hour).
SetMetadata(participantMetadata).
SetAttributes(map[string]string{
livekit.AttrIngressID: ingressID,
})
return at.ToJWT()
}