Skip to content

Conversation

@marinofranz
Copy link
Member

Description

This PR implements per-request authentication support, enabling OAuth2 bearer token authentication alongside the existing API key authentication. This is accomplished through a new withAuth() method that allows reusing a single client instance with different credentials per request.

Related Issue

Closes #5

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • ✅ Test update

Changes Made

  • Added AuthConfig type supporting both apiKey and oauth2 authentication methods
  • Implemented withAuth() method on OpenCloud class for per-request auth
  • Made OpenCloudConfig.apiKey optional (was previously required)
  • Added authOverride property to HttpClient
  • Refactored resource initialization into initializeResources() helper for maintainability
  • Updated authentication documentation guide with OAuth2 examples and multi-tenant patterns
  • Updated README with quick start examples for both auth methods

Testing

  • All existing tests pass (pnpm test)
  • Added new tests for new functionality
  • Tested manually (describe below)

Code Quality

  • My code follows the project's coding style
  • I have run pnpm lint and fixed any issues
  • I have run pnpm format to format my code
  • I have run pnpm typecheck and there are no type errors
  • I have reviewed my own code

Documentation

  • I have updated the relevant documentation (if applicable)
  • I have added/updated JSDoc comments for new/modified code

Additional Context

The proposed API design in #5 was not ideal after researching further and chose the withAuth() pattern over alternative approaches (request-level parameters, middleware, etc.) because it avoids modifying method signatures across all resources

Checklist

  • I have read the CONTRIBUTING.md guide
  • My PR title follows the Conventional Commits format
  • I have rebased my branch on the latest main branch
  • I have tested my changes against the Roblox Open Cloud API (if applicable)
  • This PR is ready for review

@marinofranz marinofranz self-assigned this Oct 31, 2025
@marinofranz marinofranz added the enhancement New feature or request label Oct 31, 2025
@marinofranz marinofranz linked an issue Oct 31, 2025 that may be closed by this pull request
3 tasks
@codecov
Copy link

codecov bot commented Oct 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@marinofranz marinofranz merged commit eff7c4f into main Oct 31, 2025
8 checks passed
@marinofranz marinofranz deleted the feature/per-request-auth branch October 31, 2025 13:50
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.

[Feature]: Per-request OAuth2 auth override

2 participants