# auth.md — UHNWI data agent registration

This service supports user-claimed agent registration. Resource server and authorization server: https://uhnwidata.com. Cloudflare Access, where configured, remains an additional outer gate. No AI Gateway or paid model is connected.

## 1. Discover
GET https://uhnwidata.com/.well-known/oauth-protected-resource for resource, authorization_servers, scopes_supported and bearer_methods_supported. GET https://uhnwidata.com/.well-known/oauth-authorization-server for issuer, token_endpoint, revocation_endpoint, grant_types_supported and agent_auth.

## 2. Choose a flow
Only service_auth is supported. Anonymous access, provider identity assertions, automatic user creation and provider security events are not supported. The human must be an existing administrator, sign in with the normal second factor and approve. No email code is sent.

## 3. Register
POST https://uhnwidata.com/agent/identity with Content-Type: application/json:
```json
{"type":"service_auth","login_hint":"<administrator email>","scope":"fields:read proposals:validate"}
```
The response contains registration_id, registration_type, claim_url, claim_token, claim_token_expires, post_claim_scopes and claim: {user_code, expires_in:600, verification_uri, interval:5}. It does not contain an identity_assertion before approval. /agent/identity/claim is only used by anonymous-start flows, which this service rejects with anonymous_not_enabled.

## 4. Hand off the claim
Show the user verification_uri and user_code together. The user signs in on this service, opens that URL and types the code there. Never ask for passwords or MFA codes. The claim URL is valid for ten minutes. The signed-in administrator must match login_hint. The approval page clearly shows this is a metadata-only grant for the displayed site.

## 5. Poll for approval
POST https://uhnwidata.com/oauth2/token as application/x-www-form-urlencoded:
```text
grant_type=urn:workos:agent-auth:grant-type:claim&claim_token=<claim_token>&resource=https://uhnwidata.com
```
Wait at least five seconds between polls. authorization_pending means wait; slow_down means back off; expired_token means register again. On approval receive access_token, token_type: Bearer, expires_in (at most 300 seconds), scope, identity_assertion and assertion_expires. Tokens and assertions are never sent to another origin. Do not put them in URLs or logs.

## 6. Exchange an assertion
POST https://uhnwidata.com/oauth2/token with grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer, assertion=<identity_assertion>, resource=https://uhnwidata.com. The HS256 service-signed oauth-id-jag+jwt assertion is audience-bound and expires after at most fifteen minutes from registration. It is only verified by this service. There is no refresh_token. The original administrator session must remain active; a token cannot outlive the registration or that session.

## 7. Use the token
Send Authorization: Bearer <access_token> only to https://uhnwidata.com/api/agent, /api/agent/mcp or /api/agent/a2a. fields:read permits only describe_fields and metadata discovery. proposals:validate permits only validate_proposal. Inputs require evidence; results do not persist. These scopes cannot read contacts, company records, personal information, mail, settings or secrets, cannot save records, and cannot run a model. Existing /api/admin and /api/account endpoints do not accept these tokens. Browser draft preparation continues to use the normal browser session and human review.

## 8. Revoke
POST https://uhnwidata.com/oauth2/revoke as form data: token=<access_token>&token_type_hint=access_token. Revocation is idempotent; it revokes that token, leaving the assertion valid until expiry. To end a whole registration, an administrator uses https://uhnwidata.com/agent/access. That invalidates the assertion and every associated token. No external identity providers or SET receiver are advertised.

## Errors and limits
invalid_scope: request only the listed scopes; service_auth_not_enabled / anonymous_not_enabled / identity_assertion_not_enabled: unsupported flow; authorization_pending: wait; slow_down: increase polling delay; expired_token / invalid_grant: restart registration; invalid_token: reauthorize or use an unexpired token; access_denied: approval was denied or revoked. Registration is limited to five per source per hour and fifty total per hour. All state transitions are audited without storing credential plaintext. Failed claims lock after five attempts.

## Service information
These are internal validation tools with no service charge or paid model call. Existing hosting quotas still apply. Terms: https://uhnwidata.com/terms.html. Privacy: https://uhnwidata.com/privacy.html. Contact: use the existing site contact page. Never send credentials or private research through public sources.
