Skip to content

Conversation

@sferik
Copy link
Owner

@sferik sferik commented Dec 26, 2025

No description provided.

Implement OAuth2Authenticator class that supports:
- Token storage (access_token, refresh_token, expires_at)
- Automatic token expiration checking via token_expired?
- Token refresh via refresh_token! method
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

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

This PR adds OAuth 2.0 authentication support with automatic token refresh capability to the X API client. The implementation follows the existing authenticator pattern and integrates seamlessly with the client's credential precedence system.

Key changes:

  • New OAuth2Authenticator class handling bearer token auth and automatic token refresh
  • Extended Client to accept OAuth 2.0 credentials (client_id, client_secret, refresh_token)
  • Comprehensive test coverage for OAuth 2.0 flows including token expiration and refresh

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
lib/x/oauth2_authenticator.rb New authenticator class implementing OAuth 2.0 with token refresh using client credentials
lib/x/client_credentials.rb Extended credential management to support OAuth 2.0 fields and authenticator selection
lib/x/client.rb Updated Client initialization to accept OAuth 2.0 credentials
sig/x.rbs Added type signatures for OAuth2Authenticator and updated Client/ClientCredentials signatures
test/x/oauth2_authenticator_test.rb Comprehensive test suite covering initialization, header generation, expiration checks, and token refresh
test/x/client_initialization_test.rb Reorganized tests into focused test classes and added OAuth 2.0 initialization tests
test/test_helper.rb Added OAuth 2.0 test constants and credential helper method

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# @return [Hash{String => Object}] the parsed response body
# @raise [Error] if the response indicates an error
def handle_token_response(response)
body = JSON.parse(response.body)

This comment was marked as resolved.

# @api private
# @return [Net::HTTP::Post] the POST request
def build_token_request
request = Net::HTTP::Post.new(TOKEN_URL)

This comment was marked as resolved.

Change TOKEN_URL and TOKEN_HOST from api.x.com to api.twitter.com
to match the rest of the client's default API host configuration.
Repository owner deleted a comment from chatgpt-codex-connector bot Dec 26, 2025
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.

2 participants