Written for: For administrators
Auth: OEM API (Web Ticket Authentication)
Web tickets sign the people who use your product in to Astrato without an Astrato password. Your backend vouches for the person by email address, Astrato returns a one-time ticket, and the person’s browser redeems it for an Astrato session. This page is the reference for those requests. For when to use web tickets rather than single sign-on, and how they fit an embedded dashboard, see Sign your own users in.
A working example application is in the public repository astrato-io/astrato-oem-integration-example.
Before you start
Section titled “Before you start”An administrator enables the OEM management API on the General tab of System settings and copies the Client ID and Client secret. The secret is shown only when you enable the API or Rotate it.
Examples use https://app.astrato.io. If your organization uses another Astrato address, use that
instead. Every request body is JSON.
The flow
Section titled “The flow”| Step | Request | Sent by | Authentication | Result |
|---|---|---|---|---|
| 1 | POST /auth/proxy/m2m/token |
Your backend | Client ID and secret | An access token, valid for 10 minutes |
| 2 | POST /oem/setup |
Your backend | The access token | A ticket, valid for 60 seconds |
| 3 | GET /auth/proxy/oem/ticket/<ticket>?embed |
The browser | The ticket | An Astrato session in that browser |
You can reuse one access token for several setup requests until it expires. Each ticket works once.
1. Get an access token
Section titled “1. Get an access token”curl https://app.astrato.io/auth/proxy/m2m/token \ --header 'Content-Type: application/json' \ --data '{ "clientId": "<client ID>", "clientSecret": "<client secret>" }'The response:
{ "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...", "expires_in": 1762866000000}| Field | Meaning |
|---|---|
access_token |
Send it as Authorization: Bearer <access_token> on the setup request. |
expires_in |
When the token expires, as a Unix time in milliseconds — not a number of seconds from now. |
A wrong client ID or secret returns 400 with code 11900 and the message
Invalid client id or client secret.
2. Ask for a ticket
Section titled “2. Ask for a ticket”curl https://app.astrato.io/oem/setup \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer <access_token>' \ --data '{ "email": "viewer@example.com", "name": "Sam Viewer", "groupNames": ["Customer viewers"] }'The response:
{ "ticket": "3f1c2a9e-5b7d-4c1e-9a2f-8d6b4e0c7a51"}| Field | Required | Meaning |
|---|---|---|
email |
Yes | The person to sign in. A ticket without one cannot be redeemed. |
name |
No | The display name given to the account if Astrato creates it. |
groupIds |
No | IDs of groups in your workspace whose permissions the person gets for this session. |
groupNames |
No | Names of groups in your workspace, used the same way as groupIds. You can send both. |
filterParameters |
No | Values for row-level filters, for this session. See Filter rows per session. |
applyPendingInvites |
No | true creates a new account from the most recent pending invitation to that address. The default is false. |
A person with no account gets one. If no account in your workspace has that address, Astrato
creates one when the ticket is redeemed. It has the Viewer role and belongs to no group, unless
you send applyPendingInvites: true and a pending invitation to that address exists: then the
account takes that invitation’s role and groups. Pending invitations to that address are removed at
that point, whether or not you apply them. Send the groups that grant access to the content the
person should open.
Groups apply to the session only. The groups you send are added to the person’s own group memberships for the session the ticket creates. They do not change their stored membership; see Manage groups and assignment rules for that. To find a group’s ID, see Managing Users and Groups with Astrato API.
The setup request can fail with:
| Status | Code | Message | Cause |
|---|---|---|---|
400 |
11119 |
Unknown groups membership requested |
A group ID or name does not exist in your workspace. The details list which ones. |
400 |
11006 |
User cannot be accessed by oem |
The address belongs to an account in another workspace. |
400 |
11902 |
Provided payload is too large |
groupIds and filterParameters together exceed 8,000 characters of JSON. |
401 |
— | — | The access token is missing, invalid or expired. |
3. Redeem the ticket in the browser
Section titled “3. Redeem the ticket in the browser”Send the ticket to the person’s browser and have the browser request it within 60 seconds. Astrato looks the ticket up, deletes it so it cannot be used again, and sets the session cookie in that browser. If the browser already had an Astrato session, the new one replaces it.
For an embed, call the ticket address from your page with credentials, then insert the iframe:
const response = await fetch(`https://app.astrato.io/auth/proxy/oem/ticket/${ticket}?embed`, { credentials: 'include',});if (!response.ok) throw new Error(`Ticket redemption failed: ${response.status}`);
const iframe = document.createElement('iframe');iframe.src = '<restricted embed link>';document.body.append(iframe);With embed, the ticket address redirects to Astrato’s embed sign-in, which sets the embedded
session and answers with an empty JSON object. It also signs the browser in to Astrato itself, so
the person can do there what the embed cannot, such as authorizing a data source.
To open Astrato directly, navigate the browser to the ticket address without embed:
https://app.astrato.io/auth/proxy/oem/ticket/<ticket>. Astrato signs the browser in and
redirects to its home page. This is how a sign-in page you host signs people in to Astrato itself;
see Use your own sign-in page.
A ticket that is unknown, already used or more than 60 seconds old returns 400 with the message
Invalid ticket. Request a new one from your backend.
The session lasts a fixed time from sign-in and is not extended by activity. For the embed settings the iframe also needs, see Embed a dashboard, and if the frame stays blank, If the frame is blank.
Filter rows per session
Section titled “Filter rows per session”filterParameters passes values to row-level filters for this session, in the same form as the
filter parameters stored against an account on the
Users screen. Each key is [<parameter name>].[<type>]
and each value is a string, number, boolean or null:
{ "email": "viewer@example.com", "groupNames": ["Customer viewers"], "filterParameters": { "[org_id].[string]": "ORG-8700", "[min_amount].[float]": 100.5, "[region].[undefined]": null }}| Type | Effect |
|---|---|
string |
Text. A string can also feed a number, date or timestamp field. |
int |
Whole number. |
float |
Decimal number. |
boolean |
true or false. |
date |
Date. |
millisec |
A timestamp, as a whole number of Unix milliseconds. |
millisec_tz |
The same, for a timestamp-with-time-zone field. |
null |
The filter matches rows where the field has no value. |
undefined |
The filter that uses this parameter is not applied. |
A row-level filter whose parameter the session carries no value for is not applied either, so a
session without the parameter sees every row that filter would have hidden. A Custom SQL table’s
{name:type} token works differently: with no value in the session it uses its default value, so
set a default that matches no customer. Send a value for every parameter your filters use, and use
undefined only for people who must see all rows, such as your own administrators.
Values sent with a ticket are combined with any stored against the account. Where both set the same name and type, the ticket’s value is used for the session.
End a person’s sessions
Section titled “End a person’s sessions”To sign a person out of every session web tickets created for them, send their address from your backend with an access token from step 1:
curl https://app.astrato.io/oem/revoke-sessions \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer <access_token>' \ --data '{ "email": "viewer@example.com" }'An address with no account in your workspace is refused. Sessions the person started by signing in to Astrato another way are left alone.
To sign out only the browser in front of you, navigate it to
https://app.astrato.io/auth/proxy/0/sign_out. This works only as a browser navigation, because
it ends the session whose cookie the browser sends; calling it from your server signs nobody out.
If people may later land on Astrato’s own sign-in page, you can show it without Astrato’s
branding; see
Hide Astrato branding on its sign-in page.
Related
Section titled “Related”- Embed a dashboard — where web tickets fit, and the embed settings they need.
- Pass any filter with one browser event — pass filters into a classic workbook embed through a browser event.
- Authentication — how each Astrato client signs in.
- Integrate with Astrato — every interface Astrato offers.