Token guidelines and behavior
- Lucidworks uses OAuth 2.0 to authenticate your credentials.
- Tokens generated by the Authentication API are Java Web tokens (JWT) tokens.
-
Every token generated is active for 3600 seconds before it expires. After that token expires, API requests attempting to use the token fail and generate an HTTP status
401 Unauthorizederror. -
You can generate a new token at any time. To avoid authorization failures, generate a new token before the current token expires. For example, generate a new token five minutes before the current token expires.
To calculate the token expiration time, Base64 decode the JWT and review the
expfield, which contains the expiration time in seconds since the Unix epoch. -
The scope for the:
-
Models API is
machinelearning.model. -
Use Case API, Prediction API, Async Prediction API, and Async Chunking API is the same and is
machinelearning.predict. Therefore, an authentication request for a token for these APIs does not affect an existing Models API token.
-
Models API is
Fetch the access token
Fetch an access token
Fetch an access token
1
Locate your integration
In the Platform UI, navigate to Models > Integrations and click on your integration.
To fetch an access token, you’ll need these details from your integration:
- Client ID
- Client secret
2
Compose your request
You’ll send your access token request using the Authentication API.The request uses basic authentication, where your base64-encoded client ID is your username and your base64-encoded client secret is your password.
Some clients perform the encoding automatically; if not, you can use the Compose your request like this:The value of the
base64 command line utility, like this:scope query parameter varies between APIs, and you need a separate access token for each scope:- The Models API uses the
machinelearning.modelscope. - All other APIs use the
machinelearning.predictscope.
3
Fetch the access token
When you send a successful Authentication API request, the JSON response looks like this:Copy the value of the
access_token key and use it for API authentication.4
Refresh your token every 60 minutes
API access tokens expire after 60 minutes.