diff --git a/livekit-api/livekit/api/_service.py b/livekit-api/livekit/api/_service.py index 31527d00..2a1e0553 100644 --- a/livekit-api/livekit/api/_service.py +++ b/livekit-api/livekit/api/_service.py @@ -18,11 +18,13 @@ def __init__( self.api_secret = api_secret def _auth_header( - self, grants: VideoGrants, sip: SIPGrants | None = None + self, grants: VideoGrants | None, sip: SIPGrants | None = None ) -> Dict[str, str]: - tok = AccessToken(self.api_key, self.api_secret).with_grants(grants) + tok = AccessToken(self.api_key, self.api_secret) + if grants: + tok.with_grants(grants) if sip is not None: - tok = tok.with_sip_grants(sip) + tok.with_sip_grants(sip) token = tok.to_jwt() diff --git a/livekit-api/livekit/api/sip_service.py b/livekit-api/livekit/api/sip_service.py index 80810528..6d3f122e 100644 --- a/livekit-api/livekit/api/sip_service.py +++ b/livekit-api/livekit/api/sip_service.py @@ -132,3 +132,20 @@ async def create_sip_participant( self._auth_header(VideoGrants(), sip=SIPGrants(call=True)), proto_sip.SIPParticipantInfo, ) + + async def transfer_sip_participant( + self, transfer: proto_sip.TransferSIPParticipantRequest + ) -> proto_sip.SIPParticipantInfo: + return await self._client.request( + SVC, + "TransferSIPParticipant", + transfer, + self._auth_header( + VideoGrants( + room_admin=True, + room=transfer.room_name, + ), + sip=SIPGrants(call=True), + ), + proto_sip.SIPParticipantInfo, + )