简体   繁体   English

后端为Javascript和Android客户端生成的令牌

[英]Sinch backend-generated token for Javascript and Android clients

I'm finding two different methods to generate the sinch auth token in an app server. 我发现了两种不同的方法来在应用服务器中生成sinch auth令牌。 One for the Android client and a different one for the JS client. 一个用于Android客户端,另一个用于JS客户端。 Is it possible to use the same token for both the android and JS clients? android和JS客户端都可以使用相同的令牌吗?

For android I see https://www.sinch.com/docs/voice/android/#authenticationsupportedbyapplicationserver which is described as using a nonce and a signature derived from 对于Android,我可以看到https://www.sinch.com/docs/voice/android/#authenticationsupportedbyapplicationserver ,它被描述为使用随机数和派生自其的签名

string stringToSign = userId + applicationKey + sequence + applicationSecret; 字符串stringToSign = userId + applicationKey +序列+ applicationSecret;

Here the response from the backend needs to have the token and the nonce and then in the android client 在这里,来自后端的响应需要具有令牌和随机数,然后在android客户端中

registrationCallback.register(signature, nonce); registrationCallback.register(signature,nonce);

For javascript it is completely different https://github.com/sinch/sinch-js-ticketgen/blob/master/index.js . 对于javascript,这是完全不同的https://github.com/sinch/sinch-js-ticketgen/blob/master/index.js
The token is generated from a json object like this 令牌是从这样的json对象生成的

{
    '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 . 其中的结果是一个带有userToken字段且带有userTicketBase64 + ':' + signature的json。 And then in the JS client 然后在JS客户端中

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? 如果没有,如何生成一个对两个都适用的客户端,以及如何初始化两个不同的客户端?

无法以一种在两种平台上都能使用的单一方式生成令牌

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在后端生成由Javascript(VueJS)生成的等效HTML - Generate equivalent HTML generated by Javascript (VueJS) on backend 使用后端生成的Javascript或CSS有什么缺点? - What are the disadvantages of using backend generated Javascript or CSS? Sinch-无法建立从网络(javascript)到移动应用(android / iOS)的呼叫 - Sinch - Unable to establish call from web (javascript) to mobile app (android/iOS) Magento 2 cms 后端 javascript 错误 Uncaught SyntaxError: Invalid or unexpected token - Magento 2 cms backend javascript error Uncaught SyntaxError: Invalid or unexpected token Sinch(javascript SDK)即时消息记录 - Sinch (javascript SDK) instant messaging history 保护客户端上的API密钥(JavaScript,Android,iOS等) - Securing API Keys on clients (JavaScript, Android, iOS, etc.) SAP Cloud SDK for Javascript:预交付 OData 服务与自生成客户端之间的区别 - SAP Cloud SDK for Javascript: difference between pre-delivered OData services VS self-generated clients 如何通过javascript将CSRF令牌添加到动态生成的表单中 - How to add CSRF Token to a dynamically generated form by javascript 从c#生成的JWT令牌与Javascript不匹配 - JWT Token generated from c# doesn't match with Javascript 如何在Android上获取JavaScript生成的HTML - How to get javascript-generated html on android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM