I'm finding two different methods to generate the sinch auth token in an app server. One for the Android client and a different one for the JS client. Is it possible to use the same token for both the android and JS clients?
For android I see https://www.sinch.com/docs/voice/android/#authenticationsupportedbyapplicationserver which is described as using a nonce and a signature derived from
string stringToSign = userId + applicationKey + sequence + applicationSecret;
Here the response from the backend needs to have the token and the nonce and then in the android client
registrationCallback.register(signature, nonce);
For javascript it is completely different https://github.com/sinch/sinch-js-ticketgen/blob/master/index.js .
The token is generated from a json object like this
{
'applicationKey': appKey,
'identity': {'type': 'username', 'endpoint': user['username']},
'created': timestamp || (new Date()).toISOString(),
'expiresIn': 86400, //24 hour default expire
}
where the result is a json with a userToken
field with userTicketBase64 + ':' + signature
. And then in the JS client
sinchClient.start(backendResponse)
This is confusing, do both clients really need completely different authentication tokens? if not, how can I generate one that works for both and how can I initialize the two different clients?
无法以一种在两种平台上都能使用的单一方式生成令牌
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.