File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 12
12
VideoGrant ,
13
13
ConversationsGrant ,
14
14
TaskRouterGrant ,
15
- ChatGrant
15
+ ChatGrant ,
16
+ PlaybackGrant ,
16
17
)
17
18
18
19
ACCOUNT_SID = 'AC123'
@@ -242,6 +243,21 @@ def test_task_router_grant(self):
242
243
'role' : 'worker'
243
244
}, decoded_token .payload ['grants' ]['task_router' ])
244
245
246
+ def test_playback_grant (self ):
247
+ grant = {
248
+ 'requestCredentials' : None ,
249
+ 'playbackUrl' : 'https://000.us-east-1.playback.live-video.net/api/video/v1/us-east-000.channel.000?token=xxxxx' ,
250
+ 'playerStreamerSid' : 'VJXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
251
+ }
252
+ scat = AccessToken (ACCOUNT_SID , SIGNING_KEY_SID , 'secret' )
253
+ scat .add_grant (PlaybackGrant (grant = grant ))
254
+ token = scat .to_jwt ()
255
+ assert_is_not_none (token )
256
+ decoded_token = AccessToken .from_jwt (token , 'secret' )
257
+ self ._validate_claims (decoded_token .payload )
258
+ assert_equal (1 , len (decoded_token .payload ['grants' ]))
259
+ assert_equal (grant , decoded_token .payload ['grants' ]['player' ])
260
+
245
261
def test_pass_grants_in_constructor (self ):
246
262
grants = [
247
263
VideoGrant (),
Original file line number Diff line number Diff line change @@ -196,3 +196,16 @@ def to_payload(self):
196
196
grant ['role' ] = self .role
197
197
198
198
return grant
199
+
200
+
201
+ class PlaybackGrant (AccessTokenGrant ):
202
+ """Grant to access Twilio Live stream"""
203
+ def __init__ (self , grant = None ):
204
+ self .grant = grant
205
+
206
+ @property
207
+ def key (self ):
208
+ return "player"
209
+
210
+ def to_payload (self ):
211
+ return self .grant
You can’t perform that action at this time.
0 commit comments