Skip to content

feat: add multi-level initial access token support for OAuth 2.0 Dynamic Client Registration (RFC 7591) #773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

andormarkus
Copy link

@andormarkus andormarkus commented Jul 16, 2025

Summary

Implements multi-level initial access token support for OAuth 2.0 Dynamic Client Registration according to RFC 7591. This enables clients to register with authorization servers that require pre-authorization for dynamic client registration.

Changes

Core Implementation

  • Extended OAuthClientProvider interface with optional initialAccessToken() method
  • Enhanced registerClient() function with multi-level fallback logic
  • Updated transport layers (StreamableHTTP & SSE) to support initial access tokens
  • RFC 7591 compliant - adds Authorization: Bearer <token> header when token available

Multi-Level Fallback Priority

  1. Explicit parameter (highest priority) - passed directly to registerClient()
  2. Provider method - via OAuthClientProvider.initialAccessToken()
  3. Environment variable - OAUTH_INITIAL_ACCESS_TOKEN
  4. None - existing behavior (backward compatible)

Usage Examples

Transport-Level Configuration

const transport = new StreamableHTTPClientTransport(serverUrl, {
  authProvider: provider,
  initialAccessToken: "your-initial-token"
});

Provider-Level Configuration

class MyOAuthProvider implements OAuthClientProvider {
  async initialAccessToken(): Promise<string | undefined> {
    return await this.loadFromSecureStorage();
  }
  // ... other required methods
}

Environment Variable

export OAUTH_INITIAL_ACCESS_TOKEN="your-initial-token"

Testing

  • 10 new comprehensive tests covering all fallback levels
  • Full test suite passes (657 tests across 33 suites)
  • Backward compatibility maintained
  • RFC 7591 compliance verified

Breaking Changes

None - this is a fully backward-compatible addition.

Related

…mic Client Registration (RFC 7591)

- Extend OAuthClientProvider interface with optional initialAccessToken() method
- Update registerClient() to support multi-level fallback:
  1. Explicit parameter (highest priority)
  2. Provider method
  3. OAUTH_INITIAL_ACCESS_TOKEN environment variable
  4. None (existing behavior)
- Add initialAccessToken option to StreamableHTTPClientTransport and SSEClientTransport
- Update auth flow to pass initial access token through all transport layers
- Add Authorization: Bearer header to registration requests when token available
- Add comprehensive test coverage for all fallback levels
- Maintain backward compatibility with servers not requiring pre-authorization

Implements RFC 7591 specification for OAuth 2.0 Dynamic Client Registration
with initial access tokens for authorization servers requiring pre-authorization.
IDE-specific files should not be committed to the repository
…mic Client Registration (RFC 7591)

- Extend OAuthClientProvider interface with optional initialAccessToken() method
- Update registerClient() to support multi-level fallback:
  1. Explicit parameter (highest priority)
  2. Provider method
  3. OAUTH_INITIAL_ACCESS_TOKEN environment variable
  4. None (existing behavior)
- Add initialAccessToken option to StreamableHTTPClientTransport and SSEClientTransport
- Update auth flow to pass initial access token through all transport layers
- Add Authorization: Bearer header to registration requests when token available
- Add comprehensive test coverage for all fallback levels
- Add detailed OAuth client configuration documentation
- Maintain backward compatibility with servers not requiring pre-authorization

Implements RFC 7591 specification for OAuth 2.0 Dynamic Client Registration
with initial access tokens for authorization servers requiring pre-authorization.
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 Initial Access Token Support for Dynamic Client Registration
2 participants