这是indexloc提供的服务,不要输入任何密码
Skip to content

feat: Allow access token grant type for federated connections #2240

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 1 commit into
base: main
Choose a base branch
from

Conversation

tusharpandey13
Copy link
Contributor

This change allows using an access token for the token exchange grant when requesting a federated connection access token. This is accomplished by adding a new subject_token_type option.

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

📋 Changes

This change introduces a subject_token_type option to the getAccessTokenForConnection method. This provides the flexibility to use an access_token for the token exchange, in addition to the existing refresh_token method. The default behavior is preserved.

Usage:

// New method using an access token
await authClient.getAccessTokenForConnection(session, {
  connection: 'my-connection',
  subject_token_type: SUBJECT_TOKEN_TYPES.SUBJECT_TYPE_ACCESS_TOKEN
});

// Default method using a refresh token
await authClient.getAccessTokenForConnection(session, {
  connection: 'my-connection'
});
  • Changed src/server/auth-client.ts: Use the new subject_token_type from options, defaulting to a refresh token if not provided.
  • Changed src/types/index.ts: Added SUBJECT_TOKEN_TYPES enum and exposed subject_token_type in AccessTokenForConnectionOptions.

📎 References

🎯 Testing

Manual:

  1. Call getAccessTokenForConnection without the new subject_token_type option.
  2. Verify the call succeeds and uses the refresh_token grant type.
  3. Call getAccessTokenForConnection with subject_token_type set to SUBJECT_TOKEN_TYPES.SUBJECT_TYPE_ACCESS_TOKEN.
  4. Verify the call succeeds and uses the access_token grant type.

… as subject_token_type in getConnectionForToken to enable usecase for auth4genai
@tusharpandey13 tusharpandey13 requested a review from a team as a code owner July 21, 2025 16:45
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.43%. Comparing base (a063a8d) to head (c18d476).
Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2240      +/-   ##
==========================================
+ Coverage   84.23%   84.43%   +0.19%     
==========================================
  Files          22       26       +4     
  Lines        2208     2383     +175     
  Branches      397      442      +45     
==========================================
+ Hits         1860     2012     +152     
- Misses        342      365      +23     
  Partials        6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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