Skip to content

Document additionalAuthorizationParams with Google refresh-token example#731

Open
jhrozek wants to merge 3 commits intomainfrom
google-params-refresh
Open

Document additionalAuthorizationParams with Google refresh-token example#731
jhrozek wants to merge 3 commits intomainfrom
google-params-refresh

Conversation

@jhrozek
Copy link
Copy Markdown
Contributor

@jhrozek jhrozek commented Apr 17, 2026

Description

Document the additionalAuthorizationParams field on upstream OIDC and OAuth 2.0 providers in the embedded authorization server. Google's access_type=offline mechanism is the motivating example — without it, Google won't issue refresh tokens even if offline_access is in the scopes.

Changes to docs/toolhive/guides-k8s/auth-k8s.mdx:

  • Extend the existing Google OIDC example (Approach 5, Step 4) to include additionalAuthorizationParams: access_type: 'offline', reorder scopes to openid, email, profile, and add a comment explaining why scopes must be set explicitly in this case.
  • Add a new ### Upstream-specific authorization parameters subsection at the end of Approach 5 with a standalone example and a "Scope interaction" note covering the default offline_access scope conflict.

The CRD reference page (docs/toolhive/reference/crd-spec.md) is autogenerated from the toolhive Go types, so it'll update automatically once stacklok/toolhive#4862 ships.

Type of change

  • Documentation update

Related issues/PRs

Closes #726

Depends on stacklok/toolhive#4862do not merge this PR until that change ships in a ToolHive release so docs don't reference a field that isn't yet available to users.

Submitter checklist

Content and formatting

  • I have reviewed the content for technical accuracy
  • I have reviewed the content for spelling, grammar, and style

Add coverage for the additionalAuthorizationParams field on upstream
OIDC and OAuth 2.0 providers, using Google's access_type=offline as
the motivating refresh-token recipe. Extend the existing Google OIDC
example, and add a dedicated subsection to the Kubernetes auth guide
covering scope interaction with the default offline_access scope.

Closes #726

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 17, 2026 14:14
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs-website Ready Ready Preview, Comment Apr 17, 2026 4:13pm

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Documents how to use additionalAuthorizationParams for upstream OIDC/OAuth2 providers in the embedded authorization server, motivated by Google’s requirement for access_type=offline to obtain refresh tokens.

Changes:

  • Extends the existing Google OIDC example to set explicit scopes and add additionalAuthorizationParams.access_type: 'offline'.
  • Adds a new “Upstream-specific authorization parameters” section with a standalone Google example and a note about default-scope interaction (offline_access).

Comment on lines +597 to +598
additionalAuthorizationParams:
access_type: 'offline'
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

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

For Google, access_type=offline is necessary but refresh tokens are typically only returned the first time the user consents; subsequent logins often require prompt=consent (or revoking prior consent) to get a refresh token again. Consider adding prompt: 'consent' under additionalAuthorizationParams or explicitly noting this limitation so readers don't assume access_type=offline alone guarantees a refresh token.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

in other words, this means that existing users who already logged in wouldn't magically get a refresh token, but would need to wait for their token to expire. It seemed better than require a consent every time. But I don't really mind one way or the other.

Comment on lines +812 to +826
upstreamProviders:
- name: google
type: oidc
oidcConfig:
issuerUrl: 'https://accounts.google.com'
clientId: '<YOUR_GOOGLE_CLIENT_ID>'
clientSecretRef:
name: upstream-idp-secret
key: client-secret
scopes:
- openid
- email
- profile
additionalAuthorizationParams:
access_type: 'offline'
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

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

The example YAML here starts at upstreamProviders: without showing the surrounding MCPExternalAuthConfig / spec.embeddedAuthServer structure. Consider either (a) including the minimal enclosing keys (or ... placeholders) to make it clear where this snippet belongs, or (b) labeling it explicitly as a partial snippet; otherwise readers may copy/paste it as-is and end up with an invalid manifest.

Suggested change
upstreamProviders:
- name: google
type: oidc
oidcConfig:
issuerUrl: 'https://accounts.google.com'
clientId: '<YOUR_GOOGLE_CLIENT_ID>'
clientSecretRef:
name: upstream-idp-secret
key: client-secret
scopes:
- openid
- email
- profile
additionalAuthorizationParams:
access_type: 'offline'
apiVersion: toolhive.stacklok.dev/v1alpha1
kind: MCPExternalAuthConfig
metadata:
name: external-auth-config
spec:
embeddedAuthServer:
upstreamProviders:
- name: google
type: oidc
oidcConfig:
issuerUrl: 'https://accounts.google.com'
clientId: '<YOUR_GOOGLE_CLIENT_ID>'
clientSecretRef:
name: upstream-idp-secret
key: client-secret
scopes:
- openid
- email
- profile
additionalAuthorizationParams:
access_type: 'offline'

Copilot uses AI. Check for mistakes.
Comment on lines +825 to +826
additionalAuthorizationParams:
access_type: 'offline'
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

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

Same as the earlier Google snippet: if the goal is to help users obtain refresh tokens reliably, consider adding prompt: 'consent' (or a short note explaining when it's needed) alongside access_type: 'offline', since Google often only returns a refresh token on the first consent without an explicit re-consent prompt.

Copilot uses AI. Check for mistakes.
jhrozek and others added 2 commits April 17, 2026 17:12
Add a "First consent only" note explaining that access_type=offline
issues a refresh token on the user's first consent only, and point to
prompt=consent as the opt-in escape hatch when that's not enough.

Addresses review feedback on PR #731.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add a title= attribute to the standalone upstreamProviders YAML block
in the "Upstream-specific authorization parameters" subsection so
readers recognize it as a partial configuration to nest inside an
MCPExternalAuthConfig, matching the pattern used for other close-up
snippets in this guide.

Addresses review feedback on PR #731.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Google OAuth example for additionalAuthorizationParams

3 participants