Skip to content

Authentication

Every ObjectsGrid request, GraphQL or REST, carries an access token:

Authorization: Bearer <access token>
X-ObjectsGrid-AccessPoint: EU

The only requests without one are the token requests themselves, registering an Organization Account, and binding its administrator with a binding code.

You get access tokens from the token endpoint, POST https://apis.objectsgrid.com/oauth2/token, which follows OAuth 2.0. The grant_type depends on who is calling:

Who calls Account grant_type Refresh token
A person using your app User Account urn:ietf:params:oauth:grant-type:token-exchange Yes
Your servers and scripts Service Account of type secret client_credentials No
A user account renewing its token User Account refresh_token Yes
Anonymous visitors of your app Service Account of type public none: a public API key No

Send the parameters form-encoded (application/x-www-form-urlencoded), as OAuth 2.0 libraries do, or as a JSON object, with the X-ObjectsGrid-AccessPoint header of your Organization Account, as with every request: it picks the data center that holds your accounts. The answer is 200 OK, with Cache-Control: no-store:

{
  "access_token": "<access token>",
  "token_type": "Bearer",
  "expires_in": 3599,
  "refresh_token": "<refresh token, user accounts only>"
}

Access tokens last one hour. A change to an account's tags applies at its next token, and a disabled account gets no new token.

Any OAuth 2.0 client library works, once it sends the X-ObjectsGrid-AccessPoint header. The endpoints are in the OAuth metadata (RFC 8414, issuer https://objectsgrid.com), and every parameter is in the Tokens contract. In Go, for example:

config := clientcredentials.Config{ // golang.org/x/oauth2/clientcredentials
    ClientID:     "<service account id>",
    ClientSecret: "<secret>",
    TokenURL:     "https://apis.objectsgrid.com/oauth2/token",
}
// the token requests carry the access point header
ctx = context.WithValue(ctx, oauth2.HTTPClient, &http.Client{Transport: accessPoint{"EU"}})
client := config.Client(ctx) // gets and renews its access token itself

with a transport that adds the header:

type accessPoint struct{ name string }

func (a accessPoint) RoundTrip(r *http.Request) (*http.Response, error) {
    r = r.Clone(r.Context())
    r.Header.Set("X-ObjectsGrid-AccessPoint", a.name)
    return http.DefaultTransport.RoundTrip(r)
}

Errors

A refused token request answers an OAuth 2.0 error:

{"error": "invalid_grant", "error_description": "The ID Token is not valid.", "correlationId": "<id for support>"}
error Status Meaning
invalid_request 400 A parameter is missing, repeated or malformed, or the X-ObjectsGrid-AccessPoint header is missing or isn't your Organization Account's
invalid_client 401 Unknown client, wrong secret, or a disabled service account
invalid_grant 400 The ID token or refresh token is expired, forged, revoked or issued to an app not in identityProviders, its nonce is wrong, its email isn't verified, or the sign-in is older than refreshTokenLifetimeHours
unauthorized_client 400 client_credentials with a public service account, or a request from an origin its allowedOrigins doesn't list
unsupported_grant_type 400 A grant_type not in the table above

The rate limit (429), the spending cap and server errors keep ObjectsGrid's usual error.

User accounts

People sign in to your app with an OpenID Connect provider: Google, Apple, or your organization's own, such as your Okta org. Your app receives an ID token and exchanges it for an access token. client_id is your Organization Account id, and nonce, optional, the nonce your app gave the provider for this sign-in:

curl -X POST https://apis.objectsgrid.com/oauth2/token \
  -H 'X-ObjectsGrid-AccessPoint: EU' \
  -d grant_type=urn:ietf:params:oauth:grant-type:token-exchange \
  --data-urlencode 'subject_token=<ID token>' \
  -d subject_token_type=urn:ietf:params:oauth:token-type:id_token \
  -d 'client_id=<organization account id>' \
  -d 'nonce=<the nonce>'
  • The User Account is created on the person's first sign-in.
  • The ID token must be issued to an app your Organization Account lists in identityProviders, or the request is refused with invalid_grant. See Sign in with Google, Sign in with Apple and Sign in with Okta.
  • An ID token from Google or Apple that carries an email must have it verified (email_verified). One from an issuer of your own may leave email_verified out, as Okta does, but not say false.
  • A nonce sent with the ID token must be the token's own. Send one: it stops a token taken from another sign-in from being replayed.
  • The answer also has "issued_token_type": "urn:ietf:params:oauth:token-type:access_token" (RFC 8693).

Two ways to sign in

A User Account can sign in with more than one provider, such as Google, Apple and your Okta org. ObjectsGrid never joins accounts by email, so the person adds the second way to their own account: signed in with the first, they send the second provider's ID token with their access token.

curl -X POST https://apis.objectsgrid.com/useraccounts/<user account id>/identities \
  -H 'Content-Type: application/json' \
  -H 'X-ObjectsGrid-AccessPoint: EU' \
  -H "Authorization: Bearer <their access token>" \
  -d '{"idToken": "<the other provider's ID token>", "nonce": "<the nonce>"}'
  • Only the account itself may, with its own access token: an administrator's is refused.
  • The ID token is checked as a sign-in checks it: issued to an app in identityProviders, its email verified, its nonce the one sent.
  • The answer is the User Account, with the sign-in among its identities. A sign-in that already opens another account is refused with 409: delete that account first, which releases its sign-ins, then link.

Service accounts

Servers, scripts and scheduled jobs sign in with a service account of type secret, using its id and secret with HTTP Basic authentication: Basic followed by the Base64 encoding of <id>:<secret>.

curl -X POST https://apis.objectsgrid.com/oauth2/token \
  -H 'X-ObjectsGrid-AccessPoint: EU' \
  -u '<service account id>:<secret>' \
  -d grant_type=client_credentials

Instead of HTTP Basic, you can send client_id and client_secret with the other parameters, but not both ways at once. A service account gets no refresh token: when its access token expires, it asks for a new one with the same credentials.

To create a service account, an administrator sends POST /serviceaccounts with {"type": "secret"}. The response holds the generated secret. Rotate it with POST /serviceaccounts/{id}/secret; the old secret keeps working for 24 hours. See Service account.

API keys

An Organization Account created without signing in, or with "bootstrapPrincipals": true, comes with three service accounts, admin, user and anonymous, and an API key for each, shown once in the create response. Send it like any access token. The admin and user keys work for 90 days; after that, those service accounts get access tokens as above. The anonymous key has no expiry: see below.

Unlike an ordinary access token, an API key follows its service account: disabling or deleting the account stops it within a minute, and it carries the account's tags as they are now, not as they were when it was made.

Anonymous access

Visitors who haven't signed in, such as people browsing your product catalog, use a service account of type public. It has no secret, so there's nothing to sign in with: your web page or app sends the account's public API key as its access token, with no token request.

An administrator makes the key:

curl -X POST https://apis.objectsgrid.com/serviceaccounts/<public service account id>/apikey \
  -H 'X-ObjectsGrid-AccessPoint: EU' \
  -H "Authorization: Bearer $ADMIN_TOKEN"
{"serviceAccountId": "<public service account id>", "apiKey": "<public API key>"}
  • No expiry. The key is public anyway: anyone can read it in your page. It works until you disable or delete its service account, which stops it within a minute. Every key you make for the account works the same way.
  • Only what every visitor may see. Give the public service account only that, through your ABAC policy.
  • Billed to you. Its requests count against your Organization Account's usage.

Two settings on the public service account limit what a copied key can do:

Field What it does
allowedOrigins The origins your pages are served from, such as ["https://shop.example.com"]. A browser request from any other origin is refused with 403, so other websites can't use your key from their visitors' browsers. Requests without an Origin header, from servers and scripts, aren't refused: this doesn't stop scripts. None listed: any origin
monthlyRequestLimit How many billable requests the key may make a month, under your spending cap. Once made, its requests get 429 until the month ends, and your other keys keep working. 0 or absent: no limit of its own

GET /serviceaccounts/{id}/usage shows an administrator the key's requests this month, by origin: each allowed origin, none (no Origin header) and unlisted (browser requests of an account that lists no origins).

If your app wants an access token instead, ask for one with the account's id alone:

curl -X POST https://apis.objectsgrid.com/oauth2/token \
  -H 'X-ObjectsGrid-AccessPoint: EU' \
  -d grant_type=urn:objectsgrid:params:oauth:grant-type:anonymous \
  -d 'client_id=<public service account id>'

client_credentials refuses a public service account with unauthorized_client: OAuth 2.0 keeps it for clients that hold a secret (RFC 6749 section 4.4).

When a public key is misused

Someone copying your key can't be told apart from your visitors, so replace the key rather than only stopping it:

  1. Create a new public service account with the same tags, such as role = anonymous. Your ABAC policy decides on tags, so the new key gets the same access.
  2. Make its API key, ship it in your site or app, and deploy.
  3. Disable or delete the old service account. Its key stops within a minute.

Both keys work between steps 1 and 3, so your visitors see no gap. To stop the old key at once, do step 3 first: your pages fail until step 2. Old versions of a mobile app keep the old key until users update: the usage of the old account shows when its traffic has died down.

Refreshing a user's access token

A user's refresh token lasts three months, or less if your Organization Account sets how long a sign-in lasts. Use it to get a new access token before the old one expires, so the user doesn't have to sign in again:

curl -X POST https://apis.objectsgrid.com/oauth2/token \
  -H 'X-ObjectsGrid-AccessPoint: EU' \
  -d grant_type=refresh_token \
  --data-urlencode 'refresh_token=<refresh token>'
  • The refresh token alone authenticates the request: no access token is needed, so it also works after the access token has expired.
  • Each refresh token works once. The response holds a new access token and a new refresh token; keep the new one.
  • With refreshTokenLifetimeHours on your Organization Account, from 1 to 2400, a sign-in lasts that many hours from when the person signed in, however often your app refreshes; then a refresh gets invalid_grant and the person signs in again. Without it, each refresh token lasts 100 days from when it was issued. See How long a sign-in lasts.

Revoking a refresh token

If a refresh token is leaked or stolen, revoke it (RFC 7009), with an access token of the same Organization Account that your ABAC policy allows to (action RevokeRefreshToken):

curl -X POST https://apis.objectsgrid.com/oauth2/token/revoke \
  -H 'X-ObjectsGrid-AccessPoint: EU' \
  -H "Authorization: Bearer $ADMIN_TOKEN" \
  --data-urlencode 'token=<refresh token>'
  • The answer is 200, also when the token was already revoked or isn't a valid token: nothing tells a caller which tokens exist.
  • token_type_hint is optional, and ignored: the token says what it is.
  • Access tokens and API keys can't be revoked (unsupported_token_type): an access token expires within the hour; disable the account (disabled: true) to stop it from getting new tokens and to stop its API keys at once.

The first token endpoints

Until 2026-11-23, each kind of account had its own endpoint, taking JSON only and answering 201 with ObjectsGrid's errors: /oauth2/token/useraccount, /oauth2/token/serviceaccount, /oauth2/token/anonymous and /oauth2/token/refresh. They still work, the same way, and will be removed once nothing calls them. Move to /oauth2/token: the same parameters work there.

Good practice

  • Keep access tokens in memory, and refresh tokens and secrets in secure storage. Never put a service account secret in a browser or mobile app: a public API key is the only credential meant for them.
  • Refresh a few minutes before expires_in runs out, rather than waiting for a 401.
  • Use a separate service account per job or server, with only the tags it needs, so you can rotate or disable one without touching the others.
  • Give each site or app its own public service account, with allowedOrigins and a monthlyRequestLimit, so a misused key is limited and replaced on its own.