Skip to content

docs(security): document OAuth access tokens on the APIToken scheme#111

Merged
steve-calvert-glean merged 3 commits into
mainfrom
add-oauth-client-api-security
Jun 15, 2026
Merged

docs(security): document OAuth access tokens on the APIToken scheme#111
steve-calvert-glean merged 3 commits into
mainfrom
add-oauth-client-api-security

Conversation

@steve-calvert-glean

@steve-calvert-glean steve-calvert-glean commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

A Glean API token and an OAuth access token are both HTTP bearer credentials, so the existing single APIToken security scheme already covers both. This overlay now only clarifies the APIToken scheme description to document OAuth usage — it no longer adds a second security scheme.

What changed since the first draft

  • Dropped the separate OAuthAccessToken scheme, the global security block, and the per-operation security removal.
  • Dropped OAUTH_SDK_DESIGN.md and the planned flattenGlobalSecurity: false + per-SDK wrapper/hook work.
  • Kept a single overlay action: an update to components.securitySchemes.APIToken.description.

Why

The second scheme forced flattenGlobalSecurity: false, which turned the flat apiToken constructor into a breaking change requiring a hand-authored shim in all four SDKs plus a coordinated rollout. Since both credentials are bearer tokens on the same Authorization header, none of that is necessary:

  • Glean API tokenapiToken
  • Glean-issued OAuth token (Authorization Server, including DCR) → apiToken; detected by issuer, no extra header
  • External-IdP OAuth tokenapiToken + the X-Glean-Auth-Type: OAUTH request header, supplied by the caller (a per-request header option on the SDKs, or a custom HTTP client)

This is a description-only spec edit; it does not change SDK generation behavior.

Follow-up

SDK usage is documented in the api-client pages on the developer site (gleanwork/glean-developer-site).

steve-calvert-glean and others added 2 commits June 15, 2026 10:29
Adds an OAuthAccessToken bearer scheme alongside APIToken and declares a global security requirement listing both as alternatives, wired into the client-bearing sources (merged + client). Enables first-class OAuth in the generated SDKs. Includes OAUTH_SDK_DESIGN.md describing the cross-SDK rollout.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@aditya-scio aditya-scio left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

aditya-scio

This comment was marked as duplicate.

@aditya-scio aditya-scio left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The core design here makes sense to me. The important insight is that this is fundamentally a spec-shape problem, not just a generator-flag problem the global security block plus flattenGlobalSecurity: false is what gets us to a sane client-level auth surface instead of scattered per-method args. The main thing I’d keep treating carefully is sequencing: publishing the spec before the SDK wrappers/hooks land would create avoidable churn, so the coordinated rollout note in the PR is important.

aditya-scio

This comment was marked as resolved.

aditya-scio

This comment was marked as duplicate.

A Glean API token and an OAuth access token are both HTTP bearer
credentials, so the existing single APIToken security scheme already
covers both. No separate OAuth scheme, global security block, or
flattenGlobalSecurity change is needed, and the SDKs keep their flat
apiToken constructor field.

- Drop the OAuthAccessToken scheme, the global security block, and the
  per-operation security removal.
- Drop OAUTH_SDK_DESIGN.md (the heavyweight wrapper/hook plan).
- Keep one action: update components.securitySchemes.APIToken.description.

External-IdP OAuth tokens still require the X-Glean-Auth-Type: OAUTH
request header, supplied by the caller. Glean-issued OAuth tokens
(Authorization Server, incl. DCR) are detected by issuer with no header.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@steve-calvert-glean steve-calvert-glean changed the title Add OAuth Client API security scheme overlay docs(security): document OAuth access tokens on the APIToken scheme Jun 15, 2026
steve-calvert-glean added a commit to gleanwork/glean-developer-site that referenced this pull request Jun 15, 2026
An OAuth access token is a bearer credential, so it goes in the existing
apiToken field. Add an OAuth section to each SDK's Authentication docs
covering the three tiers (Glean token; Glean-issued / Authorization Server
OAuth, incl. DCR; external-IdP OAuth + the X-Glean-Auth-Type: OAUTH header)
using each SDK's verified per-request header mechanism. Java uses a small
custom HTTPClient since its builder has no per-request header option.

Also correct two stale ActAs examples in the same sections: Python
headers= -> http_headers=, and Go context.WithValue -> operations.WithSetHeaders.

Supersedes the earlier draft of this PR, which injected both headers via a
full custom HTTP client in every language. Pairs with gleanwork/open-api#111.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@steve-calvert-glean steve-calvert-glean marked this pull request as ready for review June 15, 2026 19:53
@steve-calvert-glean steve-calvert-glean requested a review from a team as a code owner June 15, 2026 19:53
@steve-calvert-glean steve-calvert-glean added the enhancement New feature or request label Jun 15, 2026
@steve-calvert-glean steve-calvert-glean merged commit 0ff875a into main Jun 15, 2026
2 checks passed
@steve-calvert-glean steve-calvert-glean deleted the add-oauth-client-api-security branch June 15, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants