# Revocation and Your App

Each approval of your app starts a sign-in, usually one per device (see
[Tokens](/documentation/developers/tokens/#several-devices)). Whatever
ends a sign-in or a whole connection, your app finds out the same way:
**its next API call gets `401`.**

## What ends one sign-in

- Your app revokes the sign-in's refresh token at `/oauth/revoke`.
  Revoking an access token ends only that token.
- A refresh token comes back in a way that [Tokens](/documentation/developers/tokens/#refresh-tokens-rotate)
  lists as ending the sign-in.
- The user approves your app an eleventh time while 10 sign-ins are live:
  the least recently used one ends.
- 90 days pass without a refresh.

The user's other sign-ins with your app carry on.

Some changes you make end many sign-ins without ending a connection. If you
revoke your app's last client secret and confirm, every sign-in made with a
secret ends, and sign-ins made without one stay. Codes sent to your
backend redirect URIs fail until you create a new client secret. Revoking
one of two secrets, and removing a redirect URI or a web origin, end no sign-ins.

## What ends a whole connection

- The user disconnects your app in Connected Apps,
  `https://www.precisioncutarchery.com/app/account/connected-apps/`.
  Every token ends at once, on all their devices.
- A user logs out of all sessions, changes their email address, changes or
  resets their password, or deletes their account. These end their
  connection to every app, not only yours.
- You or we remove a test account from your app in development.
- You delete your app. Every user's connection ends.
- We suspend your app, or move it from live back to development (users who
  aren't test accounts lose their connection), or end every connection
  while leaving its status alone. Lifting a suspension doesn't restore
  them.

## What your app should do

Don't try to tell *why* a token stopped working: every cause looks the same
from your side. Your next call returns `401 UNAUTHORIZED`, and a refresh
with that sign-in's refresh token returns `invalid_grant`.

1. Treat the sign-in as gone and clear the tokens you stored for it.
2. If your app still needs to act for that user, send them back through
   [the authorization flow](/documentation/developers/authorization-flow/).
   Make reconnecting one clear action.
3. Once your app holds no live sign-in for the user, [delete their
   data](#deleting-a-users-data).

A `402 INACTIVE_SUBSCRIPTION` doesn't end the connection: the user only
needs to renew (see [Errors](/documentation/developers/errors/)).

## Deleting a user's data

The data is every result and the user's `pca_subject`. Delete it within 30
days after the first of these:

- Your last sign-in for that user has ended (`invalid_grant` on its
  refresh).
- 90 days pass without a successful refresh for that user. A user who
  uninstalled your app never gets you an `invalid_grant`, so keep the date
  of each user's last successful refresh with their data.
- The user asks you, or asks us and we pass the request on.

What your app may store, and the rest of the deletion rules, are in the
[Developer Agreement](/developer-agreement/#license) (Sections 4 to 6,
including [End Users](/developer-agreement/#end-users)). Tokens are
credentials, not data: [Tokens](/documentation/developers/tokens/#storage)
covers keeping them.
