Skip to navigation

Act for a person with an OAuth app

Call the Astropods API as a signed-in person, limited to the scopes you grant

View as Markdown

An OAuth app that acts for a person calls the Astropods API with that person’s access, capped by the scopes you grant the app. The person signs in once and approves the app. The app then holds an access token and a refresh token for them. Use one for a tool that reads an agent’s traces, logs, or evaluations on someone’s behalf.

Create the app

Creating an app requires the app:manage permission on the account, which account administrators hold.

1

Open the OAuth apps settings

Go to Settings > OAuth apps and create an app.

2

Choose the access

Select User access. Turn on Public client for a mobile, desktop, or browser app that can’t keep a secret. A public client signs in with PKCE alone and holds no client secret.

3

Grant scopes

Grant deployment:read to read deployments. Scopes use the same permission names as roles.

4

Add redirect URIs

Add the URIs your app receives the sign-in on: https, or http on a loopback host such as localhost. A public client also accepts a custom scheme, such as com.example.app:/callback.

5

Copy the app's details

Copy the client ID, and the client secret for a confidential app. The app’s row lists the authorization and token URLs.

Get a token

The app uses the OAuth 2.0 authorization code grant with PKCE.

  1. Send the person to https://login.astropods.com/oauth2/authorize with your client_id, redirect_uri, state, a PKCE code_challenge, and scope=openid profile email offline_access.
  2. The person signs in and approves the app. The browser returns to your redirect URI with a code.
  3. Exchange the code at https://login.astropods.com/oauth2/token with the PKCE verifier, and your client secret for a confidential app. The response holds an access token and a refresh token.
  4. Send the access token as Authorization: Bearer <token>. When it expires, exchange the refresh token at the same token URL.

The scope parameter carries sign-in scopes only. What the app may do comes from the scopes on the app itself, so changing them in settings applies on the next request.

Call GET /api/v1/me to check a token. For a token from an app acting for a person, it returns the person, the app and its scopes, and the app’s account while the person is still a member of it.

Read a deployment

With the deployment:read scope, the app can call the deployment endpoints that read data with GET:

DataEndpoints
The deploymentGET /api/v1/deployments/{id}, /status, /runtime, /sizing
TracesGET /api/v1/deployments/{id}/observability/traces, /traces/{traceId}, /traces/{traceId}/thread, /observations/{observationId}, /trace-users, /metrics, /summary
EvaluationsGET /api/v1/deployments/{id}/trace-evaluations, /trace-evaluations/{traceId}, /evaluations/summary, /evaluations/overview
Logs and eventsGET /api/v1/deployments/{id}/logs, /logs/stream, /events
AlertsGET /api/v1/deployments/{id}/alerts, /alerts/history, /watchers
UsageGET /api/v1/deployments/{id}/usage, /insights
FilesGET /api/v1/deployments/{id}/files, /files/usage, /files/{fileKey}, /files/{fileKey}/content
Network and resourcesGET /api/v1/deployments/{id}/network/summary, /network/flows, /network/timeseries, /pods/{pod}/metrics
ConfigurationGET /api/v1/deployments/{id}/configmap/{name}, /secret/{name}/keys

The app reads only what the person can read. A deployment the person can’t see is hidden from the app too. The deployment must also belong to the account that owns the app, even when the person belongs to other accounts.

The app can’t change a deployment. Every request that isn’t a GET or HEAD on these endpoints is refused, including ones that change only the person’s own settings, such as watching a deployment’s alerts.

Errors

StatusCause
401The token is invalid or expired, the app was deleted, or the endpoint doesn’t accept an app acting for a person. Refresh the token, or have the person sign in again.
403The token is valid, but the request isn’t allowed: it changes a deployment or uses a method other than GET or HEAD, or the app doesn’t hold the scope the endpoint needs (deployment:read for these endpoints). The error field says which.
404The deployment doesn’t exist, belongs to another account than the app, or the person can’t see it.

Revoke access

Delete the app to revoke its tokens. Every token issued for it, including tokens that haven’t expired, is refused starting with the next request. A log stream that is already open (GET /api/v1/deployments/{id}/logs/stream) continues until it disconnects. Removing the person from the account ends the app’s access to that account’s deployments the same way.

Next steps