Skip to content

Commit

Permalink
Add Authorization support to client example
Browse files Browse the repository at this point in the history
  • Loading branch information
Ceron257 committed Jun 8, 2024
1 parent 3bf544b commit 01e1640
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions protocol/webrtc/src/clients/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ <h1>WHEP Example</h1>
<label for="app-name">App Name:</label>
<input type="text" id="app-name" name="app-name" value="live">
<label for="stream-name">Stream Name:</label>
<input type="text" id="stream-name" name="stream-name" value="test">
<input type="text" id="stream-name" name="stream-name" value="test"><br>
<label for="token">Token:</label>
<input type="text" id="token" name="token" value="123">
<label for="use-header">Use Authorization header:</label>
<input type="checkbox" id="use-header" name="use-header">
<br><br>
<button id="start-whep-btn">Start WHEP</button>
</div>
Expand All @@ -106,6 +108,7 @@ <h1>WHEP Example</h1>
const appName = document.getElementById("app-name").value;
const streamName = document.getElementById("stream-name").value;
const token = document.getElementById("token").value;
const useHeader = document.getElementById("use-header").checked;

//Create peerconnection
const pc = window.pc = new RTCPeerConnection();
Expand All @@ -126,11 +129,11 @@ <h1>WHEP Example</h1>
//Create whep client
const whep = new WHEPClient();

const url = location.origin + "/whep?app=" + appName + "&stream=" + streamName + "&token=" + token;
const url = location.origin + "/whep?app=" + appName + "&stream=" + streamName + (!useHeader ? "&token=" + token : "");
//const token = ""

//Start viewing
whep.view(pc, url, token);
whep.view(pc, url, useHeader ? token : null);

});
</script>
Expand Down

0 comments on commit 01e1640

Please sign in to comment.