ApiRTC users authentication
Two different mode are available to authenticate your apiRTC users :
- Authentication using JSON Token
- Authentication using a REST request to your authentication server (third party authentication server)
Authentication Process using JSON Token
To configure authentication with JSON token you need to change your configuration in apiRTC Dashboard in menu API / Authentication
Activate JSON Token authentication :

You can also generate your secret key.
On your ApiRTC client, you simply have to use your JSON token in registerInformation.token parameter :
registerInformation.id = "my-apiRTC-UserAgent-Id"
registerInformation.token = "my-JSON-Token"
ua.register(registerInformation).then(function(session) {
// Save session
connectedSession = session;
}).catch(function(error) {
// error
console.error('User agent registration failed', error);
});
Check our blog, to get information about JSON token generation
Authentication Process with your authentication server
To configure authentication with a third party authentication server, you need to change your configuration in apiRTC Dashboard in menu API / Authentication
Activate Authentication with third party server :

You can then define your authentication server URL.
In order to authenticate your users, following process can be applied :

- 1 - Authenticate your user on your own application server thanks to its login and password.
- 2 - Generate a token and send it back to your user.
- 3 - Use this token on ua.register() thanks to the "token" parameter (as shown below) :
registerInformation.token = "myToken"
ua.register(registerInformation).then(function(session) {
// Save session
connectedSession = session;
}).catch(function(error) {
// error
console.error('User agent registration failed', error);
});
- 4 - CCS server requests your authentication server to check the token HTML GET request is send to your serverURL with following parameters : - userId - apiKey - token - webSiteUrl
- 5 - A simple checkToken API has to be deployed on your server, depending of the authentication answer, your server has to answer with a JSON string :
{"result":true} or {"result":false}
- 6 - According to the answer, the user might be allowed to connect to Apizee services or not. Prerequisites
Note : with apiRTC V3, you need to use following code :
apirtc.init({
apiKey : "myDemoApiKey",
apiCCId : "2345",
token : "abcdefghijklmnopqrst"
onReady : sessionReadyHandler
})