Skip to content

Conversation

AdamVyborny
Copy link
Contributor

@AdamVyborny AdamVyborny commented Jul 22, 2025

Summary

  • Add create_oauth_url tool for OAuth-requiring component configurations
  • Generates OAuth authorization URLs using short-lived (one hour) SAPI tokens
  • Supports components like keboola.ex-google-analytics-v4 and keboola.ex-gmail

Test plan

  • All 6 OAuth tool tests pass
  • All existing unit tests pass (247/247)
  • Tool properly registered in server
  • End-to-end testing with actual APIs and OAuth flow
  • No integration tests needed (see rationale below)

Integration Test Rationale

Integration tests were not added because:

  • Tool generates URLs for external OAuth service (external.keboola.com)
  • Core functionality (token creation + URL generation) is fully covered by unit tests
  • No direct Keboola platform interactions to test beyond existing SAPI token creation
  • OAuth flow happens entirely in external browser/service outside our control
SCR-20250722-ninx SCR-20250722-niic

🤖 Generated with Claude Code

AdamVyborny and others added 3 commits July 22, 2025 14:29
- Add create_oauth_url tool to generate OAuth authorization URLs
- Creates short-lived SAPI tokens with component-specific access
- Supports OAuth-requiring components (ex-google-analytics-v4, ex-gmail)
- Returns OAuth URL string for external authorization flow
- Add comprehensive tests with 100% pass rate
- Update server tool registry and documentation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Fix code style violations (quotes, whitespace, line length)
- Apply black formatting and isort
- Fix parametrize format in tests
- Add missing newlines at end of files
- All tests still pass (6/6)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Development information is already available in README.md

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@AdamVyborny AdamVyborny marked this pull request as ready for review July 22, 2025 13:09
@AdamVyborny AdamVyborny requested a review from a team July 22, 2025 13:09
@AdamVyborny
Copy link
Contributor Author

@jordanrburger it is working in Cursor for me :) The only disadvantage is that the user has to manually let the LLM know that it is done.

Replace raw HTTP calls with proper client method abstraction for token creation.
Add token_create method to AsyncStorageClient with comprehensive test coverage.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
AdamVyborny and others added 2 commits July 24, 2025 01:43
Replace direct session state access with proper KeboolaClient pattern
throughout the OAuth test file for consistency with project conventions.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@radcliffkey radcliffkey merged commit d1d26a0 into main Jul 25, 2025
19 checks passed
@radcliffkey radcliffkey deleted the adamvyborny-oauth-url-tool branch July 25, 2025 08:23
oauth_url = (
f'https://external.keboola.com/oauth/index.html?token={sapi_token}'
f'&sapiUrl={storage_api_url}#/{component_id}/{config_id}'
)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that the query part parameters should be properly encoded by using urllib.parse.urlencode function and the whole URL should be constructed using urllib.parse.urlunsplit function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will look into it and fix in follow-up PR. Thanks.

AdamVyborny added a commit that referenced this pull request Jul 28, 2025
Replace manual string concatenation with urllib.parse functions for secure URL construction:
- Use urlencode() for query parameters to prevent injection
- Use urlunsplit() for proper URL assembly
- Update tests to match encoded output

Addresses: #211 (comment)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
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.

3 participants