Skip to content

Commit b7ee9e0

Browse files
use SetVideoGrant instead of deprecated AddGrant (#1059)
* use SetVideoGrant instead of deprecated AddGrant * generated protobuf --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent d4fa8b9 commit b7ee9e0

File tree

6 files changed

+23
-18
lines changed

6 files changed

+23
-18
lines changed

agent/token.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func BuildAgentToken(
2525
}
2626

2727
at := auth.NewAccessToken(apiKey, secret).
28-
AddGrant(grant).
28+
SetVideoGrant(grant).
2929
SetIdentity(participantIdentity).
3030
SetName(participantName).
3131
SetKind(livekit.ParticipantInfo_AGENT).

auth/accesstoken_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ func TestAccessToken(t *testing.T) {
4343
videoGrant := &VideoGrant{RoomJoin: true, Room: "myroom"}
4444
sipGrant := &SIPGrant{Admin: true}
4545
at := NewAccessToken(apiKey, secret).
46-
AddGrant(videoGrant).
47-
AddSIPGrant(sipGrant).
46+
SetVideoGrant(videoGrant).
47+
SetSIPGrant(sipGrant).
4848
SetValidFor(time.Minute * 5).
4949
SetKind(livekit.ParticipantInfo_AGENT).
5050
SetIdentity("user")
@@ -70,7 +70,7 @@ func TestAccessToken(t *testing.T) {
7070
t.Run("missing kind should be interpreted as standard", func(t *testing.T) {
7171
apiKey, secret := apiKeypair()
7272
value, err := NewAccessToken(apiKey, secret).
73-
AddGrant(&VideoGrant{RoomJoin: true, Room: "myroom"}).
73+
SetVideoGrant(&VideoGrant{RoomJoin: true, Room: "myroom"}).
7474
ToJWT()
7575
require.NoError(t, err)
7676
token, err := jwt.ParseSigned(value)
@@ -88,7 +88,7 @@ func TestAccessToken(t *testing.T) {
8888
apiKey, secret := apiKeypair()
8989
videoGrant := &VideoGrant{RoomJoin: true, Room: "myroom"}
9090
at := NewAccessToken(apiKey, secret).
91-
AddGrant(videoGrant)
91+
SetVideoGrant(videoGrant)
9292
value, err := at.ToJWT()
9393
require.NoError(t, err)
9494
token, err := jwt.ParseSigned(value)

auth/verifier_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func TestVerifier(t *testing.T) {
5151
t.Run("unexpired token is verified", func(t *testing.T) {
5252
claim := auth.VideoGrant{RoomCreate: true}
5353
at := auth.NewAccessToken(apiKey, secret).
54-
AddGrant(&claim).
54+
SetVideoGrant(&claim).
5555
SetValidFor(time.Minute).
5656
SetIdentity("me")
5757
authToken, err := at.ToJWT()
@@ -75,7 +75,7 @@ func TestVerifier(t *testing.T) {
7575
md, _ := json.Marshal(metadata)
7676
attrs := map[string]string{"mykey": "myval", "secondkey": "secondval"}
7777
at := auth.NewAccessToken(apiKey, secret).
78-
AddGrant(&auth.VideoGrant{
78+
SetVideoGrant(&auth.VideoGrant{
7979
RoomAdmin: true,
8080
Room: "myroom",
8181
}).
@@ -102,7 +102,7 @@ func TestVerifier(t *testing.T) {
102102
}
103103
grant.SetCanPublishData(false)
104104
at := auth.NewAccessToken(apiKey, secret).
105-
AddGrant(grant)
105+
SetVideoGrant(grant)
106106
token, err := at.ToJWT()
107107
require.NoError(t, err)
108108

egress/token.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func BuildEgressToken(egressID, apiKey, secret, roomName string) (string, error)
3535
}
3636

3737
at := auth.NewAccessToken(apiKey, secret).
38-
AddGrant(grant).
38+
SetVideoGrant(grant).
3939
SetIdentity(egressID).
4040
SetKind(livekit.ParticipantInfo_EGRESS).
4141
SetValidFor(24 * time.Hour)

ingress/token.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func BuildIngressToken(apiKey, secret, roomName, participantIdentity, participan
3333
}
3434

3535
at := auth.NewAccessToken(apiKey, secret).
36-
AddGrant(grant).
36+
SetVideoGrant(grant).
3737
SetIdentity(participantIdentity).
3838
SetName(participantName).
3939
SetKind(livekit.ParticipantInfo_INGRESS).

livekit/livekit_rtc.pb.go

Lines changed: 13 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)