User Authentication
Login to 555
Currently, 555 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
Give the registered user Id and password to login.
Using app token generated from app key & app secret key, make request to 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":"<media token>","access_type":"offline","scope":"mappings"}
The Token that is received in the response, is a short-lived credential generated by server to authenticate the user. Response to a successful login request is given below:
Response: 200 OK https://aum.iris.comcast.net/v1.1/login Content-Type: application/json Trace-Id: <trace id> Responsebody: {"expires_in":"<expires in>","id":"<id>","idmapping_count":<id mapping count>,"refresh_token":<refresh token>,"routing_id":"<routing id of the registered user>","token": <token for authentication>,"user_data":{"cust_guid":"<cust_guid>","email":"<Registered email id>"}}
Using the token received in the Auth Manager response, make a request to the Identity manager to get 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":["<user email id>","<pstn number>","<registered id>"],"routing_id":"<routing id of the registered user>"}""]]
Anonymous Login
IOS SDK gives an option for the non-registered users to connect anonymously to the server.
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.
Using app token generated from app key & app secret key, make a request to Auth manager for a valid token.
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":"<user name >"}
The Token that is received as the response, is a short-lived credential generated by server to authenticate the user. Response to a successful login request is given below:
Response: 200 OK https://aum.iris.comcast.net/v1.1/login/anonymous Content-Type: application/json Trace-Id: <trace id> {"token":"<token for authentication>"}
Establish RTC Connection
A successful RTC(websocket) connection is required for a participant to initiate or join a room. IrisRtcConnection class is used to manage the connection with IRIS backend. It also involves making the necessary REST API calls with event manager and other components to get the resources required for the connection. The idea of this class is to keep a persistent connection with IRIS backend and hence it is a good practice to create the connection when app goes to foreground and disconnect when the app goes to background.
Since IrisRtcConnection is a singleton class, the following function is used to get the current instance of IrisRtcConnection & avoid creation of multiple instances.
(IrisRtcConnection *)sharedInstance;
For example,
let connection = IrisRtcConnection.sharedInstance()
Invoke connectUsingServer API to establish RTC connection with the IRIS backend:
(BOOL)connectUsingServer:(NSString* )serverUrl irisToken:(NSString*)irisToken routingId:(NSString*)routingId delegate:(id _Nullable)delegate error:(NSError* _Nullable *)outError;
Parameters | |
---|---|
serverUrl | The event manager URL |
irisToken | A valid IRIS token from Auth manager |
routingId | Routing ID of the user from Identity manager |
delegate | The delegate object for IrisRtcConnection |
outError | Provides error code and basic error description when any exception occured in api call |
let connection = IrisRtcConnection.sharedInstance()
weak var connectionDelegate = self
// attempt a connection
connection.connect(usingServer: serverUrl,
irisToken: jwtToken,
routingId:routingId,
delegate:connectionDelegate)
Disconnect from RTC Connection
The connection that is made with the IRIS backend can be disconnected using the following API.
(void)disconnect;
For example,
IrisRtcConnection.sharedInstance().disconnect()
Callbacks for RTC Connection
The IrisRtcConnectionDelegate protocol defines the optional methods implemented by delegates of the IrisRtcConnection class.
onConnected
This callback gets invoked when the connection is established successfully.
(void)onConnected;
onReconnecting
This method is called when the RTC connection is reconnecting.
(void)onReconnecting;
onDisconnected
This callback confirms disconnection from RTC server.
(void)onDisconnected;
onError
This callback gets invoked when an error occure in RTC connection.
(void)onError:(NSError *)error withAdditionalInfo:(nullable NSDictionary *)info;
Parameters | |
---|---|
error | The basic error code details |
info | Additional error details including description |
onNotification
This callback gets invoked when notification is received for RTC connection instance.
(void)onNotification:(NSDictionary *)data;
Parameters | |
---|---|
irisNotificationPayload | Notification payload |