Module: LiveKit::AuthMixin

Included in:
EgressServiceClient, IngressServiceClient, RoomServiceClient, SIPServiceClient
Defined in:
lib/livekit/auth_mixin.rb

Overview

Create authenticated headers when keys are provided

Instance Method Summary collapse

Instance Method Details

#auth_header(video_grant: nil, sip_grant: nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/livekit/auth_mixin.rb', line 6

def auth_header(
  video_grant: nil,
  sip_grant: nil
)
  headers = {}
  t = ::LiveKit::AccessToken.new(api_key: @api_key, api_secret: @api_secret)
  if video_grant != nil
    t.set_video_grant(video_grant)
  end
  if sip_grant != nil
    t.set_sip_grant(sip_grant)
  end
  headers["Authorization"] = "Bearer #{t.to_jwt}"
  headers["User-Agent"] = "LiveKit Ruby SDK"
  headers
end