W3cubDocs

/Web APIs

RTCIceServer: credential property

The RTCIceServer dictionary's credential property is a string providing the credential to use when connecting to the described server. This is typically a password, key, or other secret.

Note: This value is used when the RTCIceServer describes a TURN server.

Syntax

js

const iceServer = {
  // ...
  credential: someCredential,
  // ...
};

const credential = iceServer.credential;

iceServer.credential = newCredential;

Example

This example creates a new RTCPeerConnection which uses a TURN server at turnserver.example.org to negotiate connections. Logging into the TURN server uses the username "webrtc" and the creative password "turnpassword".

js

myPeerConnection = new RTCPeerConnection({
  iceServers: [
    {
      urls: "turn:turnserver.example.org", // A TURN server
      username: "webrtc",
      credential: "turnpassword",
    },
  ],
});

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
credential 23 ≤79 22 No 15 11 No 25 24 14 11 1.5

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/RTCIceServer/credential