SPL File IAMAccessTokenGenerator.spl

Gateway to the IBM Speech To Text (STT) cloud service > com.ibm.streamsx.sttgateway 2.2.3 > com.ibm.streamsx.sttgateway.watson > IAMAccessTokenGenerator.spl

Content

Operators
  • IAMAccessTokenGenerator: IBM Streams applications using the streamsx.sttgateway can use/invoke this non-main composite to submit, generate and periodically refresh the IAM access token which will be required by the WatsonSTT operator.
Types
  • IAMAccessToken: This type represents the data format for the result returned by the IAMAccessTokenGenerator

Composites

composite IAMAccessTokenGenerator(output stream<IAMAccessToken> IamAccessTokenStream)

IBM Streams applications using the streamsx.sttgateway can use/invoke this non-main composite to submit, generate and periodically refresh the IAM access token which will be required by the WatsonSTT operator. Without having an unexpired IAM access token, STT service on public cloud will not allow the speech to text transcription to happen.

This operator has 2 operation modes:
  • If parameter accessToken is nonempty, the operator emits one output tuple with the access token and the operator
thread ends.
  • If parameter accessToken is empty, the operator connects to the IAM authorization service specified by parameter
iamTokenURL and requests an access token by using the provided apiKey. The received access token is submitted to the output port. This operator refreshes the access token automatically after the expiration time by using the received refresh token and submits the refreshed access token to the output port. If IAM authentication server responses with a non successful result, the operator re-tries the operation after failureRetryDelay.

The operator gets the configuration information from operator parameters. These values may be overwritten from Streams Application Configuration properties if an Application Configuration with name defined by parameter appConfigName and the appropriate property exists.

Metrics: The following metrics are available if the operator generates and refreshes the access token from IAM authorization service (parameter accessToken is empty).

nSuccessfulInitialRequests: The number of successful requests with grant_type=urn:ibm:params:oauth:grant-type:apikey. The authorization was granted in response to the request

nSuccessfulRefreshRequests: "The number of successful requests with grant_type=refresh_token. The authorization was granted in response to the request.

nRequestsFailed: The cumulative number of requests which return an error status or with invalid response body.

nConnectionAttemptsFailed: The cumulative number of failed connection attempts.

nConnectionAttemptsCurrent: The number of current consecutive connection attempts until the connection succeeds. If an connection attempt succeeds, this metric is reset to 0.

Parameters

Output Ports

Types

IAMAccessToken

This type represents the data format for the result returned by the IAMAccessTokenGenerator

IAMAccessToken = rstring access_token, rstring refresh_token, rstring scope, int64 expiration, rstring token_type, int64 expires_in;