User Authentication
Login to 555
Currently, Iris platform provides various types of authentication like login through email, facebook, CIMA token. In this document, let us look into the below options:
Once the user is logged in, next step is to establish RTC connection
Login via CIMA token
Login via CIMA token involves following steps:
- Give the registered user Id and password to login.
- Using app token generated from app key & app secret key, make a request to the Auth Manager for a valid token.
Request:
HTTP POST https://aum.iris.comcast.net/v1.1/login http/1.1
Headers:
Content-Type: application/json; charset=utf-8
Content-Length: <length>
Authorization: Basic <App token>
User-Agent: <App name>/<App version><space><System http agent>
Requestbody:
{"type":"Cima","media_token":"<mediaToken>","access_type":"offline","scope":"mappings"}
The Token that is received as the response, is a short-lived credential generated by the server to authenticate the user. Response to a successful login request is as given below:
Response:
200 OK https://aum.iris.comcast.net/v1.1/login
Content-Type: application/json
Trace-Id: <trace id>
Responsebody:
{"expires_in":"<expirytime>","id":"<user_id>","idmapping_count":<count>,"refresh_token":"<refreshToken>","routing_id":"<routing_id of registered user>","token":"<iris token for authentication>","user_data":{"cust_guid":"<customer guid>","email":"<registered_email_id>"}}
- Using the token received in the previous Auth Manager response, request the Identity manager for the public id's of the user. Public Id's are the unique Id's provide to each registered user.
Request:
HTTP GET https://idm.iris.comcast.net/v1/allidentities http/1.1
Authorization: Bearer <token>
User-Agent: <App name>/<App version><space><System http agent>
A successful request will give us the following details as response:
Response:
200 OK https://idm.iris.comcast.net/v1/allidentities
Content-Type: application/json
Responsebody:
{"public_ids":["<userEmailId>","<pstn_number>","<registeredId>"],"routing_id":"<routingId of registered user>"}
Anonymous Login
Iris platform allows non-registered users to connect anonymously to the server, to perform a video call or chat.
Two parameters are required to join a room anonymously
- Room name: Name of the room to which user wants to join
- User name: Name of the user who is joining the room.
Request:
POST https://aum.iris.comcast.net/v1.1/login/anonymous http/1.1
Content-Type: application/json; charset=utf-8
Content-Length: 17
Authorization: Basic <app token>
Requestbody:
{"user_id":"<anonymous user id>"}
The response for successful request for anonymous login is as:
Response:
200 OK https://aum.iris.comcast.net/v1.1/login/anonymous
Content-Type: application/json
Trace-Id: <traceId>
{"token":"<token for authentication>"}
Establish RTC connection
A successful RTC (websocket) connection is required for a participant to initiate or join a room, using IrisRtcConnection class. Since IrisRtcConnection is a singleton class, the following function is used to get the current instance of IrisRtcConnection & avoid creation of multiple instances.
IrisRtcConnection IrisRtcConnection.getInstance();
Call this connect API to generate the xmpp server info (url/token/timestamp), which is used to connect to the RTC server.
void connect(String serverUrl, String irisToken, String routingId, final IrisRtcConnectionObserver observer, Context context, boolean anonymousLogin)
Parameters | |
---|---|
serverUrl | Event Manager URL to get the RTC server info |
irisToken | json web token for event manager REST call |
routingId | User's routing Id from Identity manager. |
observer | Listener to receive the callbacks for Rtc connection upon completion or failure of the operation.. |
context | Application context |
anonymousLogin | (Optional) - Set user type to true for anonymous user; Default - false. |
...
...
IrisRtcConnection.getInstance().connect(serverUrl, irisToken, routingId, observer, context, false);
...
...
Disconnect from RTC Connection
To disconnect from RtcConnection, use
void disconnect();
For example,
...
...
IrisRtcConnection.getInstance().disconnect();
...
...
Callbacks for RTC Connection
onConnected
This callback is called when the connection is established/successful.
void onConnected();
onDisconnect
This callback is called when the connection is disconnected.
void onDisconnect();
onError
This callback is called when there is an error.
void onError(WebRTCError.ErrorCode error, JSONObject additionalInfo);
Parameters | |
---|---|
error | The basic error code details |
additionalInfo | Additional error details including description. |
onNotification
This callback is called when notification is received for this RTC connection instance.
void onNotification(IrisNotificationPayload irisNotificationPayload);
Parameters | |
---|---|
irisNotificationPayload | Notification payload |
onReconnecting
This callback is called when trying reconnection
void onReconnecting();