Created
April 22, 2017 18:21
-
-
Save benoitongit/1d252a21cc17bb781795655d2bd085d9 to your computer and use it in GitHub Desktop.
Generate Twilio access token for video usage in ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module App | |
class Twilio | |
ACCOUNT_SID = 'XXXXXXXXXXXXXXXXX'.freeze | |
API_KEY_SID = 'XXXXXXXXXXXXXXXXX'.freeze | |
API_SECRET = 'XXXXXXXXXXXXXXXXX'.freeze | |
VIDEO_SID = 'XXXXXXXXXXXXXXXXX'.freeze | |
def generate_token(user_id) | |
# Create an Access Token for Video usage | |
token = ::Twilio::Util::AccessToken.new ACCOUNT_SID, API_KEY_SID, API_SECRET, 3600, user_id | |
# Grant access to Twilio Video | |
grant = ::Twilio::Util::AccessToken::ConversationsGrant.new | |
grant.configuration_profile_sid = VIDEO_SID | |
token.add_grant grant | |
token.to_jwt | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment