Skip to content

feat: Add PlaybackGrant #574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 14, 2021

Conversation

sarahcstringer
Copy link
Contributor

Fixes

Add PlaybackGrant.

Checklist

  • I acknowledge that all my contributions will be made under the project's license
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the Contribution Guidelines and my PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

If you have questions, please file a support ticket, or create a GitHub Issue in this repository.

@shwetha-manvinkurke shwetha-manvinkurke changed the title [feat] Add PlaybackGrant. feat: Add PlaybackGrant Oct 14, 2021
@sarahcstringer
Copy link
Contributor Author

@shwetha-manvinkurke For this one, I was able to validate that using the PlaybackGrant generated a token I could use to connect

playback_grant = Twilio::JWT::AccessToken::PlaybackGrant.new
playback_grant = {'requestCredentials' =>  nil, 'playbackUrl' =>  'https://...', 'playerStreamerSid' =>  'VJXXX'}

token = Twilio::JWT::AccessToken.new(
  account_sid, api_key, api_secret,
  [playback_grant]
)

# Generate the token
puts token.to_jwt


class PlaybackGrant
include AccessTokenGrant
attr_accessor :grant
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be too hard to break this up though. Instead of :grant, you would do something like:

attr_accessor :requestCredentials,
              :playbackUrl,
              :playbackStreamerSid

end

def _generate_payload
grant
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

payload = {}
payload[:requestCredentials] = requestCredentials if requestCredentials
payload[:playbackUrl] = playbackUrl if playbackUrl
payload[:playbackStreamerSid] = playbackStreamerSid if playbackStreamerSid

@@ -142,6 +142,20 @@
expect(payload['grants']['task_router']['role']).to eq('worker')
end

it 'Playback grant' do
playback_grant = Twilio::JWT::AccessToken::PlaybackGrant.new
grant = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

playback_grant.playbackStreamerSid = "VJXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
playback_grant.playbackUrl = "https://000.us-east-1.playback.live-video.net/api/video/v1/us-east-000.channel.000?token=xxxxx"
@scat.add_grant(playback_grant)

@shwetha-manvinkurke shwetha-manvinkurke merged commit 9ed7509 into twilio:main Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants