Skip to content

feat(middleware): add BearerTokenMiddleware for OAuth2 bearer token injection#1288

Open
robhughadams wants to merge 1 commit intoDataDog:masterfrom
robhughadams:feat/bearer-token-middleware
Open

feat(middleware): add BearerTokenMiddleware for OAuth2 bearer token injection#1288
robhughadams wants to merge 1 commit intoDataDog:masterfrom
robhughadams:feat/bearer-token-middleware

Conversation

@robhughadams
Copy link

Summary

Add BearerTokenMiddleware to support OAuth2 bearer token injection at the HTTP middleware layer. This enables client consumers to authenticate with OAuth2 bearer tokens uniformly across all API endpoints, without requiring dual-path authentication logic in each call site.

This change is proposed to unblock datadog-labs/pup#133, which fixes datadog-labs/pup#72 ("Can't query logs with OAuth").

Changes

  • src/datadog/middleware.rs (new): BearerTokenMiddleware struct implementing reqwest_middleware::Middleware — injects Authorization: Bearer <token> header on all outgoing requests when a token is configured
  • src/datadog/configuration.rs: Added bearer_token: Option<String> field, set_bearer_token() setter, and DD_ACCESS_TOKEN environment variable support
  • src/datadog/mod.rs: Exported pub mod middleware and re-exported BearerTokenMiddleware
  • Cargo.toml: Added async-trait = "0.1" and task-local-extensions = "0.1" dependencies

Related Issues

@robhughadams robhughadams requested review from a team as code owners February 27, 2026 17:15
@robhughadams robhughadams marked this pull request as draft February 27, 2026 17:16
@robhughadams robhughadams force-pushed the feat/bearer-token-middleware branch from 96b2fd8 to adad828 Compare February 27, 2026 17:17
@robhughadams robhughadams changed the title refactor(middleware): add BearerTokenMiddleware for OAuth2 bearer token injection feat(middleware): add BearerTokenMiddleware for OAuth2 bearer token injection Feb 27, 2026
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.

[BUG] Can't query logs with OAuth

1 participant