Это настройка, которая работает для меня. Я запускаю сервер локально, чтобы получить текущие токены. Таким образом, мне не нужно включать какие-либо секреты в клиент.
window.fetch( 'http://localhost:3500/directline/token', { method: 'POST' } )
.then( function ( res ) {
return res.json();
} )
.then( function ( res ) {
let token = res.token;
window.fetch( 'http://localhost:3500/speechservices/token', { method: 'POST' } )
.then( function ( res ) {
return res.json();
} )
.then( function ( res ) {
let authorizationToken = res.authorizationToken;
window.WebChat.renderWebChat( {
directLine: window.WebChat.createDirectLine( {
token: token,
webSocket: true
} ),
webSpeechPonyfillFactory: window.WebChat.createCognitiveServicesSpeechServicesPonyfillFactory( {
region: 'westus2',
authorizationToken: authorizationToken
} )
}, document.getElementById( 'webchat' ) );
});
} );
Надеюсь на помощь!