Skip to main content
How you authenticate depends on whose account the orders belong to: Either way, every API request sends the token as a bearer token:

Personal access tokens

AGS issues a personal access token for your AGS account, with the scopes your integration needs. Send it as the bearer token. There’s no sign-in flow and nothing to refresh. Orders you create belong to your account, and you see the orders placed with any of your account’s tokens.
The token is shown once, when it’s created. Keep it on your server, like a password, and never ship it in a mobile or browser app.
Tokens last one year. To replace a token, ask AGS for a new one, switch your integration to it, then ask AGS to revoke the old one. A revoked or expired token gets a 401 with the unauthenticated error code.

OAuth client credentials

AGS registers your app and gives you its credentials. Tell us your app’s redirect URIs when you register.
The client secret is shown once, when it’s created. Store it securely on your server and never ship it in a mobile or browser app.
Redirect URIs must match exactly. Mobile apps can use a custom scheme, such as yourapp://callback.

Scopes

Request scopes as a space-separated list. If you request none, the token gets orders:read. Each endpoint in the API reference lists the scope it needs, and a token without it gets a 403 with the insufficient_scope error code.

Connect a customer

1

Create a PKCE code verifier and challenge

Generate a random code_verifier of 43 to 128 characters, and derive the code_challenge as the base64url-encoded SHA-256 hash of it. PKCE is required for public apps, and we recommend it for confidential apps too.
2

Send the customer to the authorize URL

The customer signs in to AGS if needed, then sees which app is asking and what it will be able to do.
3

Handle the redirect

If the customer approves, AGS redirects to your redirect_uri with code and state query parameters. Check that state matches the value you sent. If the customer denies access, the redirect carries error=access_denied instead.The code expires after 10 minutes and can be used once.
4

Exchange the code for tokens

The response contains the tokens:

Refresh the access token

Access tokens last one hour. Use the refresh token to get a new pair before or after the access token expires:
Public apps leave out client_secret. Refresh tokens last 30 days and can be used once. Each refresh returns a new refresh token, so store it in place of the old one.
Errors from /oauth/authorize and /oauth/token follow the OAuth 2.0 format, with error and error_description fields. API endpoints use the format in Errors.

When tokens stop working

With OAuth, a customer’s tokens are revoked, and your app has to connect them again, when:
  • The refresh token expires after 30 days without use.
  • The customer changes their AGS password.
  • AGS revokes your app’s client.
API requests with a revoked or expired access token get a 401 with the unauthenticated error code.