-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refresh Speech Services authorization token to use speech more than 10min. #1912
Comments
@corinagum will follow up. The sample is at https://github.com/Microsoft/BotFramework-WebChat/blob/master/samples/06.c.cognitive-services-speech-services-js/index.html. It support both subscription key or authorization token for Cognitive Services. In this sample, the token is generated once from our API server. We should update this sample to cache/generate it from our Mockbot. The documentation for that work is at https://github.com/compulim/web-speech-cognitive-services#using-authorization-token. Instead of putting a |
I think we need to make our sample better by default, so people don't fall into this hole. You are right, the Cognitive Services package support Promise for authorization token. We should update our sample so it will call/cache the authorization token. |
We could use some code similar to this. It will only refresh the token after 10 minutes and cache it through memoization. const fetchAuthorizationToken = memoize(
() => {
return fetch('https://webchat-mockbot.azurewebsites.net/bingspeech/token', { method: 'POST' })
.then(res => res.json())
.then(({ token }) => token);
},
(x, y) => Math.abs(x - y) < 60000
); |
Fixed in #2429. |
Hello!
I am wondering if a refresh of the speech authorization token is implemented? As it is now, when using a token it expires after 10 minutes as described in this documentation:
https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/rest-speech-to-text
Also in this documentation it's mentioned to show how to get, how to use and how to refresh a token. ("In the next few sections you'll learn how to get a token, use a token, and refresh a token.") But the refresh section isn't there so I'm at a loss of how to refresh my token without having to rerender my webchat (like hitting f5).
I know that it's possible to use the subscription key instead and I have tried and it works. But isn't that a major security risk?
Kind regards,
Shariele
The text was updated successfully, but these errors were encountered: