SightCall Developer Center

Account Login Support

Authenticate

This section is dedicated to the authentication of users on the SightCall Platform.
The system is designed so that the application can keep control of their users. That is why no credential information is stored in the SightCall Platform. Authentication is done on the application side, then users are provisionned on the cloud by the application backend. Once done, a token is given to the SDK user to be able to conenct to the cloud.

As there are two families of users (internal and external) that mainly differ on the authentication methods side , this document is divided in two chapters.

Internal Users

Pre-Requisites

You should know your App Identifier that is available at account.sightcall.com.
APPID here

You should also need your API Key that is the concatenation of your Authentication API Client Identifier and your Authentication API Client Secret. These two fields are also available at account.sightcall.com.

Credentials here

Step by Step

Internal Authentication here

Step 1 - User Authentication

This step is not handled on the SightCall platform at all. It is handled by your application front-end and back-end and should allow you to identify or authenticate the user. At this stage, your backend should know exactly who is connected.

Step 2 - Generate or retreive the App Id of the User

Again, this step is not handled on the SightCall platform. During this step, the backend assigns a UID (Rtcc User Id) to the user. This UID is used for all SightCall operations, like calling someone, or sending a message. You can choose to keep your internal id as UID or pick up a new one dedicated to the SightCall Platform. It has to be unique and as it is used to reach someone, it has to stay constant for a user. An internal user should keep the same UID during his lifetime.

IMPORTANT WARNING: RTCC Platform only knows the UID of users. Should you need to keep your users identities secret, we strongly recommend to generate UID that can not be directly linked to login or email and store them in your backend. Then when an user wants to perform any operation with another one, your application can retrieve the UID from the second user and do the operation.

Step 3/4 - Request a token to the Rtcc Cloud

Requesting a token from the SightCall platform is done through the REST APIs. The method to request a token is part of the REST provider API.

The Application back-end is authenticated through its API Key located in the header of the REST Request.

Three fields are available in the POST body of the request and only one is mandatory:

You can assign a new ID to a profile at account.sightcall.com that shows the list of profiles that you have purchased.

Profiles ID here

Some samples to request a token:

<?php

// API Url
$url = "https://api.rtccloud.net/v2.0/provider/usertoken";
// Client ID and Client Secret
$client_id = "";
$client_secret = "";

// Set the uid, domain and profile as appropriate for your RTCC installation
$params = array(
    'uid'       => '',
    'domain'    => '',
    'profile'   => ''
);

// Init Curl
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Apikey ' . $client_id . $client_secret));

$output = curl_exec($ch);

if($output === false)
{
    // Sample failure output:
    // {"success":false,"message":"Profile premium_recording_plus not found"}
    throw new Exception(sprintf('Curl error: "%s"', curl_error($ch)));
} else {
    // Sample success output:
    // {"success":true,"data":"834ccf4e7d2983970a11b8311f8c6a2ce5d31046"}
    echo $output;

}
?>
#!/usr/bin/env ruby

require "net/https"
require "uri"
require "json"

uri = URI.parse("https://api.rtccloud.net/v2.0/provider/usertoken")

client_id = ""
client_secret = ""

uid = ""
domain = ""
profile = ""

net = Net::HTTP.new(uri.host, uri.port)
net.use_ssl = true
net.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(uri.request_uri)
request.initialize_http_header({"Authorization" => "Apikey #{client_id}#{client_secret}"})
request.set_form_data({"uid" => uid, "domain" => domain, "profile" => profile})

response = net.request(request)

if response.code == "201"
    body = response.read_body
    puts body
end
var https = require('https');
var querystring = require('querystring');

var client_id = "";
var client_secret = "";

var data = querystring.stringify({
    uid: "",
    domain: "",
    profile: ""
});

var options = {
    host: 'api.rtccloud.net',
    path: '/v2.0/provider/usertoken',
    method: 'POST',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Content-Length': Buffer.byteLength(data),
        'Authorization': 'Apikey ' + client_id + client_secret
    }
};

callback = function(response) {
    var str = ''
    response.on('data', function(chunk) {
        str += chunk;
    });

    response.on('end', function() {
        if (response.statusCode === 201) {
            console.log(str);
        }
    });
}
var req = https.request(options, callback);
req.write(data);
req.end();
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;

public class Main {

public static void main(String[] args) throws Exception {
        String clientId = "";
        String clientSecret = "";
        String uid = "";
        String domain = "";
        String profile = "";

        URL url = new URL("https://api.rtccloud.net/v2.0/provider/usertoken");
        HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Authorization", "Apikey " + clientId + clientSecret);
        connection.setDoOutput(true);
        connection.getOutputStream().write(("uid=" + uid + "&domain=" + domain + "&profile=" + profile).getBytes());
        connection.connect();

        if (connection.getResponseCode() == HttpURLConnection.HTTP_CREATED) {
            try (BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
                String result = br.readLine();
                System.out.println(result);
            }
        } else {
            try (BufferedReader br = new BufferedReader(new InputStreamReader(connection.getErrorStream()))) {
                String result = br.readLine();
                System.out.println(result);
            }
        }
        connection.disconnect();
    }
}

Step 5 - Forward the token to the front-end of your application

Another Application to Application interface where the Rtcc platform is not involved.
Step 1 to 5 can be merged to one step on the user interface as the token can be sent back to the user during his authentication phase. It's important that the front-end side of your application has access to the token to be able to have the SDK authenticated.

Step 6/7 - Instantiate and authenticate the SDK using the provided token

The last step is to instantiate the SDK of the technology your are using (JavaScript, Android, iOS), to pass it the token and wait for the event that notifies you the SDK is sucessfully connected.

To instantiate the SDK:

var options = {
    debugLevel : 1, 
    displayName : 'YOUR_DISPLAY_NAME'
};

var rtcc = new Rtcc("APP_IDENTIFIER", "TOKEN", "internal", options);
//Calling Rtcc.instance instantiate the SDK the first time
//Calling Rtcc.instance instantiate the SDK the first time
public void initialize(String appid, Context context) {
    Rtcc.initialize(appid, context);
}

Associate some callbacks or delegate if needed:

rtcc.on('cloud.sip.ok',readyToCall);
rtcc.on('presence.ok', fullyReady)
[[Rtcc instance] setDelegate: (id<RtccDelegate>)YourDelegateObject];
Rtcc.instance().delegate = YourDelegateObject

And launch the connection/authentication process:

rtcc.initialize();
[[Rtcc instance] connectWithAppID:appID andUserType:[UserType UserTypeInternalWithToken:token]];
Rtcc.instance().connectWithAppID(appID, andUserType:UserType(internalWithToken:token))
public void authenticate(Context context, String token) {
    Rtcc.instance().authenticate(RtccEngine.UserType.internal(token));
}

@RtccEventListener
public void onAuthenticated(AuthenticatedEvent event) {
    if (event.isSuccess()) {
        // The user is authenticated, you can set a display name, create a call, …
        Rtcc.instance().setDisplayName("Android");
    } else {
        // An error occured during authentication
    }
}

IMPORTANT WARNING: In WebRTC - as Chrome enhanced the security since Chrome 47 - it is mandatory to host the pages embedding the javascript client in HTTPS and in a web server (not the file system). In case of http hosting, any call will be immediately canceled with an error relative to secure origin in the javascript console.

External Users

Pre-Requisites

To log an external user, it is mandatory to have a premium plus user connected. The external user is dependent on his/her "referent" internal premium plus user. He/she is the only one that the external user can call. Refering to a non-existing user or to a user with a lower profile does not allow access to the SightCall platform.

Step by Step

External Authentication here

The workflow for external users is more simple, as no token is required.

Step 1/2 - Instantiate and authenticate the SDK using the provided token

This mechanism is the similar as the authenticated user mechanism, but instead of giving a token the external user indicates the UID of his referent internal user. He/she also needs to give the parameter "external" instead of the "internal" one.

var rtcc = new Rtcc("APP_IDENTIFIER", "Referent UID", "external", options);
[[Rtcc instance] connectWithAppID:AppID andUserType:[UserType UserTypeExternalWithParentID:@"Referent UID"]];
Rtcc.instance().connectWithAppID(appID, andUserType:UserType(externalWithParentID:"Referent UID"))
public void authenticate(Context context, String uid) {
    Rtcc.instance().authenticate(RtccEngine.UserType.external(uid));
}

6-Digit Users

6-digit users are a unique kind of external users. A plus can request a 6-digit code - from the SightCall backend - that an external user can connect to the platform. As an external user, he/she will only be able to call (or join a conference call) created by the one who generated the code. This feature is usually used to give the code through other ways than a standard web app. For exemple it can be sent through SMS or during a phone call.

Pre-Requisites

The pre-requisites of 6-digit users are exactly the same as the ones of external users: it is mandatory to have a premium plus user connected.
The plususer should also be connected in desktop. Only desktop clients can create a 6-digit code, even though any kind of client can use it to connect.

Creating a 6-digit code

Creating a six-digit code is done using the Javascript SDK method: createSixDigits. Two or three parameters may be used:

rtcc.createSixDigits('1', 'Alice');

And the code is received through the event sixdigits.create.success.


function functionToDisplayTheCode(theCode){
    console.log(theCode);
}
rtcc.on('sixdigits.create.success', functionToDisplayTheCode)

Authenticating as a 6-Digit User

Authenticate as a 6-Digit External user is very similar to authenticate as a standard external, but the keyword is 'digit_external' instead of 'external'.

var 6Digits='123456';
var rtcc = new Rtcc("APP_IDENTIFIER", 6Digits, "digit_external", options);