[PR #2472] feat(tools): Preliminary OAuth Integration and Testing for API-based Tool Workflow #23659

Closed
opened 2026-02-21 20:21:31 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/2472

State: closed
Merged: No


Description

This pull request is integrates OAuth support within the API Based tool workflow.

Key updates and enhancements include:

  • Extending tool_entities.py to support OAuth, enabling tools to utilize OAuth authentication and authorization effectively.
  • Enhancing ApiBasedToolProviderController with OAuth-specific fields like client_id, client_secret, authorization_url, and token_url to the credentials schema, increasing flexibility for OAuth configurations.
  • Refining serialization and enum handling in common_entities.py and tool_entities.py to ensure accurate and internationally compatible OAuth support within tool credentials.
  • Implementing OAuth authentication type in the from_db method of ApiBasedToolProviderController, enriching the credentials schema to support a wider range of OAuth use cases.
  • Adding new ToolCredentialsOption entries in ToolProviderCredentials for extended authentication flexibility.
  • Updating .github/workflows/tool-tests.yaml and .gitignore for aligned CI processes and cleaner project structure.
  • Creating integration tests in test_api_tool.py and test_tool_provider_credentials.py to cover the new OAuth functionality and validate the serialization of tool provider credentials, ensuring existing authentication methods remain operational.

The integration tests are crucial in verifying the presence and correct types of expected keys in the credentials schema for each authentication type, ensuring the schema's accuracy and completeness.

Together, these changes significantly broaden the authentication capabilities of tool providers, enabling more secure and versatile integrations with API-based tools and services.

Fixes # (issue)

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update, included: Dify Document

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • pytests included

Suggested Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
  • optional I have made corresponding changes to the documentation
  • optional I have added tests that prove my fix is effective or that my feature works
  • optional New and existing unit tests pass locally with my changes
**Original Pull Request:** https://github.com/langgenius/dify/pull/2472 **State:** closed **Merged:** No --- # Description This pull request is integrates OAuth support within the API Based tool workflow. Key updates and enhancements include: - Extending `tool_entities.py` to support OAuth, enabling tools to utilize OAuth authentication and authorization effectively. - Enhancing `ApiBasedToolProviderController` with OAuth-specific fields like `client_id`, `client_secret`, `authorization_url`, and `token_url` to the credentials schema, increasing flexibility for OAuth configurations. - Refining serialization and enum handling in `common_entities.py` and `tool_entities.py` to ensure accurate and internationally compatible OAuth support within tool credentials. - Implementing OAuth authentication type in the `from_db` method of `ApiBasedToolProviderController`, enriching the credentials schema to support a wider range of OAuth use cases. - Adding new `ToolCredentialsOption` entries in `ToolProviderCredentials` for extended authentication flexibility. - Updating `.github/workflows/tool-tests.yaml` and `.gitignore` for aligned CI processes and cleaner project structure. - Creating integration tests in `test_api_tool.py` and `test_tool_provider_credentials.py` to cover the new OAuth functionality and validate the serialization of tool provider credentials, ensuring existing authentication methods remain operational. The integration tests are crucial in verifying the presence and correct types of expected keys in the credentials schema for each authentication type, ensuring the schema's accuracy and completeness. Together, these changes significantly broaden the authentication capabilities of tool providers, enabling more secure and versatile integrations with API-based tools and services. Fixes # (issue) ## Type of Change Please delete options that are not relevant. - [ ] Bug fix (non-breaking change which fixes an issue) - [X] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) # How Has This Been Tested? Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration - [X] pytests included # Suggested Checklist: - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] My changes generate no new warnings - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods - [ ] `optional` I have made corresponding changes to the documentation - [ ] `optional` I have added tests that prove my fix is effective or that my feature works - [ ] `optional` New and existing unit tests pass locally with my changes
yindo added the pull-request label 2026-02-21 20:21:31 -05:00
yindo closed this issue 2026-02-21 20:21:31 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#23659