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.
Authentication scope
You must specify one or more values for thescope of each authentication request.
The values depend on which API you use:
Fetch the access token
Fetch an access token
Fetch an access token
1
Locate your client ID and secret
Where you find the client ID and secret depends on which API you’re using:
- For Lucidworks AI APIs, go to Models > Integrations and click your integration, then copy the Client ID and Client Secret. Learn more about Lucidworks AI integrations.
- For Commerce Studio APIs, go to Settings > Service Accounts and click your service account, then copy the Client ID and Client Secret. Learn how to create a service account.
2
Compose your request
Send your access token request to the authentication endpoint.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
A successful request returns: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.