Repository navigation
feat: TEA 1.0.0 API key exchange at /token and discovery failover at /discovery - #42
Merged
vpetersson merged 2 commits intoNov 17, 2026
Conversation
…h as ones with userinfo or a query
…oints at /discovery On a 1.x server basic_auth is an API key: it now goes only to POST /token (client_credentials, each part form-encoded before Basic) and the access token is sent as the bearer token, replaced once per request after a 401 invalid_token challenge. 0.4.0 servers keep plain Basic auth. TeaClient.from_tei(tei) resolves a TEI through .well-known/tea and uses /discovery as the probe: connection errors, 5xx, a non-TEA 404 or an invalid body move to the next endpoint, while a TEA error 404, 401 or 403 ends discovery. The CLI's discover, inspect and TEI download use it.
8 of 9 tasks
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
vpetersson
approved these changes
Nov 17, 2026
This was referenced Nov 18, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #34. These two commits were pushed to its branch after it was merged, so they never reached master. They close the remaining "shall" gaps against the TEA 1.0.0 discovery and auth rules.
basic_authis an API key. It goes only toPOST /token(client_credentialsover HTTP Basic, each part form-encoded first per RFC 6749 §2.3.1), and the access token is sent as the bearer token.auth/readme.mdsays a client "shall not" present an API key to a resource endpoint, which the client did until now. A token rejected with a401carrying aninvalid_tokenchallenge is replaced, and the request retried, once. Concurrent requests share one exchange. 0.4.0 servers keep plain Basic auth on every request./discovery:TeaClient.from_tei(tei)returns(client, results). It tries the.well-known/teaendpoints in the orderfrom_well_knownwould and uses/discoveryas the probe. Connection errors, 5xx, a 404 that is not a TEA error, or an invalid body move to the next endpoint; a TEA error 404 (such asOBJECT_UNKNOWN), 401 or 403 ends discovery, asdiscovery/readme.mdrequires.from_well_knownfollowed bydiscovercould not fail over at that step. The CLI'sdiscover,inspectand TEIdownloaduse it when no--base-urlis given..well-knownendpoint URLs:TeaEndpoint.urlnow uses the.well-knownschema's own pattern, so a URL with userinfo, a query, a fragment or a trailing slash is rejected. Before,/v1.0.0would be appended inside a query string, andrequeststurns userinfo into Basic auth that replaces the caller's credentials.Behaviour changes
basic_authagainst a 1.x server now callsPOST /tokenfirst. A base URL without a/v<semver>suffix counts as 1.0.0, so code usingbasic_authwith a 0.4.0 server at such a URL needsspec_version="0.4.0"(noted in the README's Upgrading section).--base-urlno longer send a HEAD probe before/discovery.Changes by layer
/token, one renewal oninvalid_token,_read_jsonshared byget_jsonand the exchangefrom_tei,from_well_knownandfrom_teishare one candidate loop (_connect),api_key_exchangeon 1.xTeaEndpoint.urlpattern from the.well-knownschema_tei_sessionfordiscover,inspectand TEIdownloadTest plan
/token, form-encoding of the key parts, 0.4.0 Basic auth unchanged, one renewal and no second retry, OAuth error types, invalid token responses, one exchange under concurrency, failover on each listed failure, no failover on a TEA 404, 401 or 403, the URN form resolved only at 0.4.0 endpoints, endpoint URLs inside and outside the schema patternmypy,ruff check .,ruff format --check .clean