【发布时间】:2018-11-01 05:00:21
【问题描述】:
我正在寻找两种不同的方法来在应用服务器中生成 sinch 身份验证令牌。一种用于 Android 客户端,另一种用于 JS 客户端。 android和JS客户端可以使用同一个token吗?
对于安卓我看到https://www.sinch.com/docs/voice/android/#authenticationsupportedbyapplicationserver 这被描述为使用随机数和从
派生的签名string stringToSign = userId + applicationKey + sequence + applicationSecret;
这里后端的响应需要有token和nonce 然后在android客户端中
registrationCallback.register(signature, nonce);
对于 javascript,它完全不同 https://github.com/sinch/sinch-js-ticketgen/blob/master/index.js。
令牌是从这样的 json 对象生成的
{
'applicationKey': appKey,
'identity': {'type': 'username', 'endpoint': user['username']},
'created': timestamp || (new Date()).toISOString(),
'expiresIn': 86400, //24 hour default expire
}
结果是一个带有userToken 字段和userTicketBase64 + ':' + signature 的json。
然后在 JS 客户端中
sinchClient.start(backendResponse)
这令人困惑,两个客户端真的需要完全不同的身份验证令牌吗?如果没有,我怎样才能生成一个同时适用于两者以及如何初始化两个不同的客户端?
【问题讨论】:
标签: javascript android sinch android-sinch-api