Authenticate
Lattice supports two authentication methods: OAuth 2.0 client credentials using short-lived access token, environment token authentication, using long-lived, static access tokens.
Environment token
Client credentials
The environment token is a long-lived, static bearer token you use the token to authenticate with Lattice. You must rotate the token before it expires:
OAuth 2.0 client credentials is in beta and not widely deployed in production Lattice environments. If you’re developing an integration in a production Lattice environment, check with your Anduril representative to confirm whether OAuth 2.0 is available.
OAuth 2.0 client credentials exchange a client ID and secret for a short-lived token. REST SDKs manage the client credential lifecycle automatically, while gRPC integrations require that you refresh the token:
The following steps show how to authenticate using both client credentials and long-lived environment tokens with both REST and gRPC SDKs.
Before you begin
- Set up the Lattice SDK.
- If you are using Lattice Sandboxes, see the Sandboxes set up guide. If you are using a Lattice deployment other than Sandboxes, obtain your Lattice endpoint and access credentials from your Anduril representative.
Get the Lattice endpoint
To store the Lattice endpoint as a system environment variable, do the following:
Get your credentials
To store your credentials as system environment variables, do the following:
Sandboxes token
If you’re connecting to Sandboxes:
This is required for Sandboxes whether you use client credentials, or an environment token. If you do not have a Sandboxes token, create a new token.
Environment token
Bearer token authentication uses a long-lived, static token to authenticate requests. Use this method when your deployment provides a static access token rather than OAuth 2.0 client credentials.
The reusable client you build in Install
uses this method: its common module reads ENVIRONMENT_TOKEN and attaches it to every request, so
you don’t pass the token yourself.
Using REST
The common client passes the token to the SDK client’s token option. To use it, get the client from
common, then call the API:
Using gRPC
For gRPC, the common client attaches the bearer token as metadata on every outgoing request, with the
gRPC library’s per-call credentials or interceptor mechanism. To use it, get the client from
common, then call the API:
Client credentials
OAuth 2.0 client credentials is in beta and not widely deployed in production.
If you’re developing an integration in a production Lattice environment, check with your Anduril representative if
OAuth 2.0 is available.
When you use OAuth, Lattice exchanges your credentials for a short-lived access token using the
Lattice OAuth REST endpoint. To use client credentials, add an
oauth module next to the client in your project’s common module. It builds the same client as
Install, with client credentials in
place of the environment token.
Using REST
The REST SDK handles fetching a new access token automatically, so the oauth module passes your
client ID and secret when it creates the client:
Then get the client from the oauth module, and call the API:
Using gRPC
Since gRPC does not provide built-in OAuth token management, the oauth module implements a
ClientCredentialsAuth type that fetches an access token, caches it, and refreshes it before it expires:
Then connect with ClientCredentialsAuth in place of the environment token, and call the API:
These examples refresh the access token before it expires, with a buffer of about five minutes. Each gRPC call
asks ClientCredentialsAuth for the token, which returns the cached token or refreshes it if needed.
What’s next?
- See Connect to offline environments to configure a trusted CA certificate for air-gapped environments.
- Learn how to publish entities to Lattice.
- Explore tasking to learn how to task an agent in Lattice.