IBM Cloud auth bearer tokens (access_token
) expire in one hour. Two questions:
Is there a specific error message that signals that the access_token
has expired? Not the general error message HTTP Authentication failed; no valid credentials available
. Specifically, does the Speech-to-Text SDK send a message here
stream.on('message', function(message, data) {
when the access_token
has expired?
Second question: this answer says that
there is no benefit of using the grant_type refresh_token over getting a new access token
To confirm that I understand that, the refresh_token
should never be used; I should just get a new access_token
?
I would recommend to use IAMAuthenticator to handle everything. See the up-to-date Speech documentation here. You linked to RecognizeStream which seems to be deprecated.
There is an example on how to use the IAMAuthenticator for the initial authentication. That object then handles the refresh automatically.