Last active
June 20, 2024 20:37
-
-
Save abelorian/200696537b8b4e1bee5ac2caeb7f624a to your computer and use it in GitHub Desktop.
Agora dynamic Key ruby RTC example. Gem agora_dynamic_key https://rubygems.org/gems/agora_dynamic_key
This file contains hidden or 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
# In Gemfile: gem 'agora_dynamic_key', '~> 0.1.0' | |
require 'dynamic_key' | |
class Agora | |
EXPIRATION_TIME_IN_SECONDS = 3600*3 | |
def generate_rtc_token channel_name = 'any_channel_name' | |
params = { | |
app_id: '970CA35de60c44645bbae8a215061b33', | |
app_certificate: '5CFd2fd1755d40ecb72977518be15d3b', | |
channel_name: channel_name, | |
uid: 0, # important: 0 for testing | |
role: AgoraDynamicKey::RTCTokenBuilder::Role::PUBLISHER, | |
privilege_expired_ts: Time.now.to_i + EXPIRATION_TIME_IN_SECONDS | |
} | |
AgoraDynamicKey::RTCTokenBuilder.build_token_with_uid params | |
end | |
end | |
# Test in console: Agora.new.generate_rtc_token "prueba1" | |
# "0069e2660ec8cd74be7bae7d56a24dd2fa0IACWEy4sNhSrCYRGLLPKb/HKASHDKJAHSDKASDHIUWHJBJKWKJABKJSDBJKABJSDKJBASDbkj5e" | |
# source: https://github.com/AgoraIO/Tools/blob/master/DynamicKey/AgoraDynamicKey/ruby/sample/rtc_token_builder_sample.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment