IBM Cloud auth refresh_token to refresh expired access_token?

317 views Asked by At

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?

1

There are 1 answers

0
data_henrik On

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.