Skip to content

Commit 9ed7509

Browse files
Add PlaybackGrant. (#574)
1 parent dd605d3 commit 9ed7509

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

lib/twilio-ruby/jwt/access_token.rb

+13
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,19 @@ def _generate_payload
267267
payload
268268
end
269269
end
270+
271+
class PlaybackGrant
272+
include AccessTokenGrant
273+
attr_accessor :grant
274+
275+
def _key
276+
'player'
277+
end
278+
279+
def _generate_payload
280+
grant
281+
end
282+
end
270283
end
271284
end
272285
end

spec/jwt/access_token_spec.rb

+14
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,20 @@
142142
expect(payload['grants']['task_router']['role']).to eq('worker')
143143
end
144144

145+
it 'Playback grant' do
146+
playback_grant = Twilio::JWT::AccessToken::PlaybackGrant.new
147+
grant = {
148+
'requestCredentials' => nil,
149+
'playbackUrl' => 'https://000.us-east-1.playback.live-video.net/api/video/v1/us-east-000.channel.000?token=xxxxx',
150+
'playerStreamerSid' => 'VJXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
151+
}
152+
playback_grant.grant = grant
153+
@scat.add_grant(playback_grant)
154+
payload, _ = JWT.decode @scat.to_s, 'secret'
155+
expect(payload['grants'].count).to eq(1)
156+
expect(payload['grants']['player']).to eq(grant)
157+
end
158+
145159
it 'multiple grants' do
146160
room_grant = Twilio::JWT::AccessToken::VideoGrant.new
147161
room_grant.room = 'RM123'

0 commit comments

Comments
 (0)