Skip to content

feat(java/driver/flight-sql): add OAuth2 support#4272

Closed
lxyzxx wants to merge 0 commit intoapache:mainfrom
lxyzxx:main
Closed

feat(java/driver/flight-sql): add OAuth2 support#4272
lxyzxx wants to merge 0 commit intoapache:mainfrom
lxyzxx:main

Conversation

@lxyzxx
Copy link
Copy Markdown
Contributor

@lxyzxx lxyzxx commented Apr 27, 2026

Summary

This PR provides an initial implementation of OAuth2 authentication support for the Java Flight SQL ADBC driver.

It introduces a configurable OAuth2 mechanism that allows clients to acquire and attach access tokens when establishing Flight SQL connections.

Changes

  • Add OAuth2-related connection options

    • token endpoint
    • client credentials
    • grant type (initial support focuses on client credentials flow)
  • Introduce FlightSqlOAuthTokenProvider

    • Responsible for acquiring and refreshing access tokens
    • Encapsulates OAuth2 logic from the connection layer
  • Integrate OAuth authentication into FlightSqlConnection

    • Automatically attaches Authorization: Bearer <token> header
  • Add validation for conflicting authentication configurations

    • Prevent simultaneous usage of:
      • username/password
      • custom Authorization headers
      • OAuth2 configuration
  • Add unit tests for OAuth2 authentication behavior

Future Work

  • Consider whether OAuth2 support should be standardized across ADBC drivers
  • Potentially introduce a common authentication abstraction at the ADBC layer

Closes #4277.

@lxyzxx lxyzxx requested a review from lidavidm as a code owner April 27, 2026 16:02
@lxyzxx lxyzxx changed the title feat(java/flight-sql): add OAuth2 support [ADBC][Java] Add OAuth2 authentication support to Flight SQL driver Apr 28, 2026
@lxyzxx
Copy link
Copy Markdown
Contributor Author

lxyzxx commented Apr 28, 2026

Linked issue: #4277

@lidavidm lidavidm changed the title [ADBC][Java] Add OAuth2 authentication support to Flight SQL driver feat(java/driver/flight-sql): add OAuth2 support Apr 30, 2026
Copy link
Copy Markdown
Member

@lidavidm lidavidm left a comment

Choose a reason for hiding this comment

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

FWIW, would using the existing Go Flight SQL driver via the JNI bridge work for you?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a standard library/common third party library we can leverage for OAuth details?

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.

Thanks for the suggestions.

I’d prefer to keep this in the pure Java Flight SQL driver instead of relying on the Go driver through JNI, since JNI would introduce native dependencies and additional deployment complexity for Java users.

For the OAuth2 implementation, I agree that we should use an existing library rather than hand-roll the protocol details. I noticed that Arrow Java already uses Nimbus OAuth2 SDK, so I think Nimbus would be a good fit for Java ADBC as well. I’ll update the PR accordingly.

Copy link
Copy Markdown
Contributor

@xborder xborder Apr 30, 2026

Choose a reason for hiding this comment

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

arrow-java implementation was based on the GO ADBC implementation and slightly changed to use Nimbus OAuth2 SDK. I think we could try to approximate ADBC and JDBC implementations, it might be possible to use arrow-java implementation since it seems ADBC has arrow-java as a dependency

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.

That makes sense. Since ADBC currently depends on Arrow Java 18.3.0 and the Arrow Java OAuth classes are not available in that version yet, directly reusing the JDBC implementation would require bumping the Arrow Java dependency.

Would you prefer that I refactor the ADBC implementation in this PR to more closely mirror the Arrow Java JDBC OAuth structure, or should we wait until ADBC updates to an Arrow Java version that includes those OAuth classes and then reuse the implementation ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it is ok to bump arrow-java version. 19.0.0 already got released. That way, refactoring the implementation to make it closer to arrow-java would be simpler

lidavidm pushed a commit that referenced this pull request May 1, 2026
### Summary

Upgrade the Java modules from Arrow Java 18.3.0 to 19.0.0.

This is intended as a prerequisite for refactoring the Java Flight SQL
OAuth implementation to reuse the OAuth abstractions added in Arrow Java
19.0.0.

Follow-up to the discussion in:
#4272 (comment)

---------

Co-authored-by: xinyu.lin <xinyu.lin@transwarp.io>
@lxyzxx lxyzxx closed this May 1, 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.

[ADBC] Support OAuth2 authentication in Flight SQL Java driver

3 participants