I am currently exploring two distinct methods for creating the sinch authentication token on an app server. One approach is designed for the Android client while the other is tailored for the JS client. Is it feasible to utilize the same token for both the android and JS clients?
On the Android side, I came across this resource, which involves using a nonce and a signature derived from:
string stringToSign = userId + applicationKey + sequence + applicationSecret;
The backend response in this case must include the token and the nonce, then on the android client side:
registrationCallback.register(signature, nonce);
However, the process is entirely different for JavaScript found at this link. The token is generated from a json object structured like this:
{
'applicationKey': appKey,
'identity': {'type': 'username', 'endpoint': user['username']},
'created': timestamp || (new Date()).toISOString(),
'expiresIn': 86400, //24 hour default expire
}
The resulting json contains a userToken
field with
userTicketBase64 + ':' + signature
. Subsequently, in the JS client:
sinchClient.start(backendResponse)
This distinction raises questions: do both clients truly require completely disparate authentication tokens? If not, how can I generate one token that serves both clients and how can I initialize them accordingly?