Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure WebRTC with Coturn and oAuth

I want to use coturn with oAuth. If I understood it correctly I need to do two things:

  • Storing the oAuth tokens in the database coturn is using
  • Sending the ACCESS-TOKEN and USERNAME STUN attributes

First point is clear but how do I need to change my WebRTC client to achieve the second point?

Without oAuth I would initialize my RTCPeerConnection like this:

var configuration = {
  'iceServers': [{
    'url': 'turn:turn.example.org',
    'username': 'user',
    'credential': 'password'
  }]
};
var pc = new RTCPeerConnection(configuration)

The WebRTC 1.0 draft defines a RTCIceCredentialType enum so i would think I need to change my configuration like this:

var configuration = {
  'iceServers': [{
    'url': 'turn:turn.example.org',
    'username': 'kid',
    'credential': 'oAuthToken',
    'credentialType': 'token'
  }]
};

Using Wireshark I can't see the ACESS-TOKEN attribute. Any ideas or does anyone know a working example?

like image 252
lefloh Avatar asked Jul 28 '15 15:07

lefloh


1 Answers

It seems like things changed a bit since original question was asked. The webrtc-pc#1033 pull-request alters the spec and introduces the following iceServers configuration syntax:

var configuration = {
    'iceServers': [{
        "urls": "turns:turn.example.net",
        "username": "username",
        "credential": {
            "macKey": "...",
            "accessToken": "..."
        },
        "credentialType": "oauth"
    }],
    ...
}

See RTCIceServer documentation page for more configuration examples.

like image 176
firegurafiku Avatar answered Sep 20 '22 18:09

firegurafiku