Sign in with altengine
Your app sends the person to altengine. They sign in, pick an organization, see exactly what your app asks for and click Authorize. Your app then receives an ordinary API key (ae_…) holding that access and nothing more. Nobody copies or pastes a key.
Any app can do this with no registration: it identifies itself with a small JSON file on a domain it controls.
It is standard OAuth 2.0: the authorization code flow with PKCE (RFC 6749, RFC 7636), loopback redirects for native apps (RFC 8252), the device flow (RFC 8628), revocation (RFC 7009), and Client ID Metadata Documents instead of client registration. An OAuth library that does PKCE works as-is.
Endpoints
| Endpoint | URL |
|---|---|
| Authorize | GET https://console.altengine.net/api/oauth/authorize |
| Token | POST https://console.altengine.net/api/oauth/token |
| Device authorization | POST https://console.altengine.net/api/oauth/device_authorization |
| Revocation | POST https://console.altengine.net/api/oauth/revoke |
Use these URLs as written. The authorization server metadata at /.well-known/oauth-authorization-server describes the MCP connector, and its authorize and token endpoints do not accept a URL client_id.
1. Publish a client metadata document
Your client_id is the HTTPS URL of a JSON file describing your app. Host it anywhere you control: your website, GitHub Pages, a bucket with a custom domain.
// https://example.com/altengine-client.json
{
"client_id": "https://example.com/altengine-client.json",
"client_name": "Example Desktop",
"client_uri": "https://example.com",
"redirect_uris": ["http://127.0.0.1/callback"],
"token_endpoint_auth_method": "none"
}| Field | Required | Meaning |
|---|---|---|
client_id | yes | The document's own URL, character for character. |
redirect_uris | yes | 1–10 addresses the code may be sent to: https://, or http://127.0.0.1/… / http://[::1]/…. A loopback entry matches any port, so list it without one. |
client_name | no | Shown on the consent screen, up to 80 characters. Defaults to the domain. |
client_uri | no | Your homepage, linked from the consent screen. https:// only. |
token_endpoint_auth_method | no | Must be none if present. There is no client secret; PKCE protects the code. |
The URL must be https://, have a path, and have no query string or fragment. Serve the file with status 200 and JSON content, at that exact URL (redirects are not followed), and keep it under 16 KB. altengine caches it for up to five minutes, so a change to it can take that long to show.
2. Send the person to authorize
Make a PKCE pair, start a listener on a free loopback port, and open the system browser at the authorize URL:
https://console.altengine.net/api/oauth/authorize
?response_type=code
&client_id=https://example.com/altengine-client.json
&redirect_uri=http://127.0.0.1:53127/callback
&code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM
&code_challenge_method=S256
&state=af0ifjsldkj
&scope=org:read instances:write datastore:full:example* functions:full:example*
&device_name=ANA-PC| Parameter | Value |
|---|---|
response_type | code |
client_id | Your metadata document's URL. |
redirect_uri | One your document lists. For a loopback entry, use the port you are listening on. |
code_challenge | base64url(SHA-256(code_verifier)), no padding. The verifier is 43–128 characters of A–Z a–z 0–9 - . _ ~. |
code_challenge_method | S256. plain is refused. |
state | A random value you check when the browser comes back. Up to 512 characters. |
scope | What your app needs, space-separated. See Scopes. |
device_name | Optional. What you call this computer, up to 64 characters. It goes into the key's name and decides which key is replaced on re-authorizing. |
When the person clicks Authorize, the browser lands on redirect_uri?code=…&state=…. When they click Cancel, it lands on redirect_uri?error=access_denied&state=…. Other problems arrive the same way with error set to invalid_request, invalid_scope or unsupported_response_type, plus an error_description. An unknown client_id, a document that cannot be fetched, or a redirect_uri your document does not list is shown to the person as an error page and is never redirected.
3. Exchange the code
Within ten minutes, and once only:
curl -X POST https://console.altengine.net/api/oauth/token \
-d grant_type=authorization_code \
-d code=... \
-d client_id=https://example.com/altengine-client.json \
-d redirect_uri=http://127.0.0.1:53127/callback \
-d code_verifier=...{
"access_token": "ae_Xk3f9a.Xk3f9aQm…",
"token_type": "Bearer",
"scope": "instances:write datastore:full:example* functions:full:example*",
"altengine": {
"key_id": "6a1f…",
"key_name": "Example Desktop (example.com) — authorized by [email protected] on 2026-11-19 (ANA-PC)",
"org_id": "…",
"org_name": "Acme",
"replaced": false
}
}access_token is an API key. Send it as Authorization: Bearer … to https://api.altengine.net/v1/… and to the MCP server. It has no expiry and no refresh token. Keep it in the operating system's credential store, and authorize again if a call answers 401.
scope is what was granted, which can be less than you asked for: the person's role in the organization caps it. Read it rather than assuming.
error | Meaning |
|---|---|
invalid_grant | The code is unknown, expired, already used, or was issued for another client_id or redirect_uri; or the verifier does not match; or the person has since left the organization. Start again. |
invalid_client | Unknown client_id, your document cannot be fetched, or the app has been disabled. |
unsupported_grant_type | Use authorization_code, or the device grant below. |
Scopes
Each scope is something an API key can hold: a permission to manage the organization's instances, or a grant on data.
| Scope | Lets the key |
|---|---|
org:read or instances:read | List instances and read their configuration over MCP. |
instances:write | Also create instances and change their configuration over MCP, within its grants. |
functions:inspect | List functions, versions and errors over MCP. |
functions:deploy | Deploy and activate functions over MCP. |
usage:read | Read usage over MCP. |
<service>:<level>:<prefix>* | Have <level> on every instance of the service whose name starts with <prefix>, including ones created later. With full, create them. |
<service>:<level>:<name> | Have <level> on one instance. |
<service>:<level> | Have <level> on every instance of the service. The consent screen warns about this one. |
<service> is search, channel, datastore, auth, functions, blob, static, mailbox, tasks or container; <level> is read, write or full. A prefix needs at least three characters, and * matches zero or more, so example* covers an instance named example too. Automation and deleting instances cannot be requested. Without an org:, instances:, functions: or usage: scope the key works on /v1 only, not over MCP.
Ask for a prefix, not a service. Name every instance your app creates with one prefix and request that: the person keeps everything else in the organization out of your app's reach, and sees on the consent screen which of their existing instances the prefix already covers.
An app that provisions its own backend, creating a datastore, auth, a function and a static site and then redeploying the function on each upgrade, asks for:
org:read instances:write
datastore:full:example* auth:full:example* functions:full:example* static:full:example*It needs full to create each instance. A function it deploys may be given grants only within the key's own, so datastore:full:example* also bounds what the function can reach.
What the person sees
- Your
client_name, the domain your document is served from, and Not verified, worded as a claim: "an app calling itself Example Desktop, published at example.com". - The
device_nameyou sent, and where the key will be delivered (for a loopback redirect, "on this computer"). - An organization picker. The key is for that organization only.
- Each scope in plain words, with what their role in that organization allows. A scope the role cannot give is struck through, and your app does not get it.
- For each prefix, the existing instances it covers there now.
- The instance limit, if your app may create instances.
Billing, members and API keys are never available to an app.
The key afterwards
- It is listed on the organization's API keys page, marked as an app's key and named after your app, the person and the device. Anyone who can manage it there can revoke it, or narrow it; nobody can give it more than was authorized.
- Authorizing again replaces it. The same app, person, organization and
device_nameget the same key with a new secret and the newly granted access; the old secret stops working at once. Send a stabledevice_nameper machine so each machine keeps its own key. - It is revoked when the person who authorized it leaves the organization, resets their password, or removes a linked GitHub or Google account.
- Revoking takes effect within about a minute.
To sign out, revoke it yourself:
curl -X POST https://console.altengine.net/api/oauth/revoke \
-d token=ae_… \
-d client_id=https://example.com/altengine-client.jsonThe answer is always 200. Only the app a key was issued to can revoke it this way.
Headless machines: the device flow
For a CLI on a server with no browser. The person opens a URL on any device, types a code, and sees the same consent screen. The device flow is available to verified apps that have it enabled.
curl -X POST https://console.altengine.net/api/oauth/device_authorization \
-d client_id=https://example.com/altengine-client.json \
-d "scope=org:read instances:write datastore:full:example*" \
-d device_name=build-01{
"device_code": "…",
"user_code": "BDWP-HQKT",
"verification_uri": "https://console.altengine.net/device",
"verification_uri_complete": "https://console.altengine.net/device?user_code=BDWP-HQKT",
"expires_in": 900,
"interval": 5
}Show the person verification_uri and user_code, then poll the token endpoint every interval seconds:
curl -X POST https://console.altengine.net/api/oauth/token \
-d grant_type=urn:ietf:params:oauth:grant-type:device_code \
-d device_code=… \
-d client_id=https://example.com/altengine-client.json| Answer | Do |
|---|---|
authorization_pending | Wait interval seconds and poll again. |
slow_down | You polled too soon. Wait longer before the next poll. |
access_denied | The person cancelled. Stop. |
expired_token | Nobody approved it within 15 minutes. Start again. |
200 | The same key response as the code exchange. |
Verified apps
altengine can mark an app Verified: the consent screen then shows the publisher's name and a badge instead of the domain and "Not verified". A verified app can also be given the device flow, and a ceiling on what it may ask for. To ask, contact us with your client_id. A verified app can use a short client_id such as example-desktop instead of a URL; it can then redirect only to http://127.0.0.1:<port>/callback or http://[::1]:<port>/callback.
Complete example (Node.js)
A desktop or CLI sign-in in one file, with no dependencies. Run it with node sign-in.mjs (Node 18 or later).
// sign-in.mjs
import http from "node:http";
import crypto from "node:crypto";
import os from "node:os";
import { execFile } from "node:child_process";
const CONSOLE = "https://console.altengine.net";
const CLIENT_ID = "https://example.com/altengine-client.json"; // lists "http://127.0.0.1/callback"
const SCOPE = "org:read instances:write datastore:full:example* functions:full:example*";
const b64url = (buf) => buf.toString("base64url");
const verifier = b64url(crypto.randomBytes(32));
const challenge = b64url(crypto.createHash("sha256").update(verifier).digest());
const state = b64url(crypto.randomBytes(16));
function openBrowser(url) {
if (process.platform === "win32") execFile("rundll32", ["url.dll,FileProtocolHandler", url]);
else execFile(process.platform === "darwin" ? "open" : "xdg-open", [url]);
}
const server = http.createServer();
server.listen(0, "127.0.0.1", () => {
const redirectUri = `http://127.0.0.1:${server.address().port}/callback`;
const url = new URL(`${CONSOLE}/api/oauth/authorize`);
url.search = new URLSearchParams({
response_type: "code",
client_id: CLIENT_ID,
redirect_uri: redirectUri,
code_challenge: challenge,
code_challenge_method: "S256",
state,
scope: SCOPE,
device_name: os.hostname(),
});
console.log("Opening your browser to sign in…");
openBrowser(url.toString());
server.on("request", async (req, res) => {
const back = new URL(req.url, redirectUri);
if (back.pathname !== "/callback") return res.writeHead(404).end();
if (back.searchParams.get("state") !== state) return res.writeHead(400).end("State mismatch.");
const error = back.searchParams.get("error");
if (error) {
res.end("Not connected. You can close this tab.");
server.close();
console.error(error === "access_denied" ? "Cancelled." : back.searchParams.get("error_description"));
return;
}
const r = await fetch(`${CONSOLE}/api/oauth/token`, {
method: "POST",
headers: { "content-type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
grant_type: "authorization_code",
code: back.searchParams.get("code"),
client_id: CLIENT_ID,
redirect_uri: redirectUri,
code_verifier: verifier,
}),
});
const token = await r.json();
res.end(r.ok ? "Connected. You can close this tab." : "Something went wrong. Check the app.");
server.close();
if (!r.ok) return console.error(token.error, token.error_description);
// Store token.access_token in the OS credential store, not in a plain file.
console.log(`Connected to ${token.altengine.org_name} with: ${token.scope}`);
});
});Then, for example, list the instances the key can see over MCP:
curl -X POST https://api.altengine.net/mcp \
-H "Authorization: Bearer $KEY" -H "content-type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"list_instances","arguments":{}}}'