Skip to content
LogoLogo

About app authentication

Picked sends requests to the server of an app, and the app sends requests to Picked. Each side must know that a request comes from the other side. This page answers two questions. How does each side identify the other? Why does the server of an app hold one private key and no other data?

The exact headers, fields and time limits are in App protocol.

Two private keys, and no shared secret

Picked and each app have their own Ed25519 private key and public key. Each side keeps its private key, and gives only its public key to the other side.

  • Picked signs each request that it sends to an app. Picked publishes its public keys at /.well-known/picked-app-keys.json on its API. The app gets them from there. It uses them to verify that Picked signed each request.
  • The app signs its requests to Picked. The app registers its public key with Picked. picked app deploy registers it. A person can also add the key on the page of the app in the dashboard. Picked uses that key to verify the requests of the app.

The result: Picked holds no secret of an app. If a person gets a copy of the data of Picked, that copy contains no credential of an app. The app can verify that Picked signed a request, but the app cannot sign as Picked. In the same way, Picked cannot sign as the app.

A shared secret is the alternative. Picked and the app then sign with the same value. That design is less work. But each side can then sign as the other side. Picked must also keep a secret for each app, and a copy of that store in the wrong hands would expose every app.

The picked-app-assertion token

When the app calls Picked, it first makes a short token, and signs it with its private key. The app sends this token in the picked-app-assertion header. The token identifies the installation that the app acts for, and the Picked API that the token is for.

Picked accepts each picked-app-assertion token one time only, for that API only, and for five minutes at most. Picked also uses the keys of the app of that installation to verify it. So a copy of the token is of no use to another person. An app also cannot act for an installation of a different app.

The picked-app-assertion token gives access to one operation only: appInstallationTokenCreate. That operation gives the app an installation token. The app then calls the API with that token, the same as other clients.

Installation tokens

An installation token acts as the installation. It carries the scopes that the installation got when a person accepted the app. It can also read and write the labels of the installation. It expires one hour after Picked makes it.

Picked puts a new installation token in each request that it sends to an app. Examples are a workflow tool call, an event, or a request from the AI agent. So an app that only answers Picked does not have to make a token. The token in the request is enough.

This is the default, and it is deliberate. An app acts on a project while Picked asks it to act, and for one hour after that at most. When the app does not get requests, it has no access to the project.

Session tokens

A page of an app in the dashboard comes from the server of the app. The page must tell its server which person looks at it, and on which installation. For this, the dashboard gets a session token from Picked, and gives it to the page. The page sends it to the server of the app.

Picked signs the session token with its own key. The server of the app uses the public keys of Picked to verify it. The app cannot make a session token. So a valid session token shows that a person is in the dashboard on that installation now. A session token expires after ten minutes.

Access outside a request

Some apps must act when no person is in the dashboard and Picked sends no request. An example is an app that copies data at fixed times. Such an app asks for offlineAccess in its manifest. The person who installs it sees this in the consent window, below the scopes.

The difference shows in appInstallationTokenCreate:

  • With offlineAccess, the app can get a token at any time.
  • Without offlineAccess, the app must also send a session token for that installation.

Without offlineAccess, an app can get a token only while a person uses its page. The app cannot go around this rule, because it cannot make a session token. The rule therefore holds against the app itself, and not only against other persons.

OAuth with another service

Many apps connect an installation to another service with OAuth. The person clicks a button on the page of the app, and the service opens in a new window. Some time later, the service sends the browser back to the callback address of the app. That callback is a new request. It does not come from Picked, and it carries no session token.

Therefore the app must send its state through the service, and get it back on the callback. The state contains the installation, and the session token of the person who started the connection. The app encrypts the state with a key that it derives from its private key. The service cannot read or change the state, and the app needs no second secret. On the callback, the app opens the state. Then it gets an installation token with that session token, and keeps the grant of the service in a label.

The session token never goes in an address. The page gives it to the new window with a message, and the window sends it to the server of the app in a header. An address can go into the history of the browser, into logs, or to a different site.

A state that is correct is not enough. A person can start a connection, and then send the address of the service to a different person. If the second person gives access, the callback keeps the account of the second person in the installation of the first person. The same problem occurs when a different person sends a callback address with their own code to a person who is signed in.

So the start of the flow sets a cookie in the browser, and puts the same value in the state. The callback completes only when the browser sends that cookie. A different browser does not have it. The callback then deletes the cookie, so that the same callback cannot complete two times.

The cookie has HttpOnly, so a script cannot read it, and SameSite=Lax, so the browser sends it when the service sends the browser back. Its name starts with __Host-. The browser then keeps it for the host of the app only, and only over https:. OAuth cookie gives the name on a local http: address.

The cost is one flow at a time for each browser and app. A second start replaces the cookie, and the first flow fails. The flow also fails when the callback is on a different host from the start.

The state and the cookie expire after ten minutes. The session token in the state expires ten minutes after Picked made it.

Why the app holds no other data

The server of an app needs only its private key. Each request from Picked identifies the installation and the address of the Picked API to call back. The data of each installation stays in Picked, as labels. So the app can run as a function with no files and no database.

When the app marks a label as secret, Picked keeps the value in a secure store. Only the installation can read the value back, with its own token. A person who reads the labels of the installation sees an empty value. This choice is the responsibility of the author. A refresh token in a label that is not secret is visible to each person who can read the installation.

About apps tells what happens to the labels when a person removes the app.

Two keys for each app

An app can hold two public keys at most. With two keys, an app can replace its key and continue to work. The app registers the next public key first, and then holds two keys. Picked accepts tokens that either key signed. The server of the app then moves to the next private key.

Last, the app removes the old public key. See How to rotate an app key.

Picked can replace its own key in the same way. After it changes its private key, it can continue to publish the old public key. Then a request that the old key signed still verifies.

The cost of this design

Each app must get the public keys of Picked, and keep them for a short time. The app gets the keys again when a request names a key that it does not know. If an app cannot get to the Picked API, it cannot verify a request that a new key signed.

The labels of an installation also have limits. See How to store data for an installation.