Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add async get_raw_access_token() method to AsyncPipedream#264

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Copilot wants to merge4 commits intomain
base:main
Choose a base branch
Loading
fromcopilot/make-raw-access-token-async

Conversation

Copy link

CopilotAI commentedDec 12, 2025
edited by coderabbitaibot
Loading

Description

raw_access_token performs blocking network calls when using OAuth authentication, which blocks the event loop in async applications (FastAPI, Django ASGI, etc.).

Changes

  • AsyncPipedream: Addedasync_raw_access_token async property for non-blocking token retrieval
  • Existingraw_access_token property preserved for backwards compatibility

Usage

frompipedreamimportAsyncPipedreamclient=AsyncPipedream(client_id="...",client_secret="...",project_id="...")# Non-blockingtoken=awaitclient.async_raw_access_token
Original prompt

This section details on the original issue you should resolve

<issue_title>Make raw_access_token async to support non-blocking use in async contexts</issue_title>
<issue_description>Description

Currently, accessingclient.raw_access_token appears to perform a blocking network call to fetch the OAuth token. This blocks the event loop when used inside async applications.

Proposed solution:

  • Provide an async variant, e.g. awaitclient.raw_access_token, or
  • Lazily initialize and refresh the token via an async mechanism under the hood when usingAsyncPipedream.

This would make the SDK safer to use in async frameworks (e.g. FastAPI, Django ASGI) without blocking.</issue_description>

<agent_instructions>Please make sure that the change is backwards compatible</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our2 minute survey.

Summary by CodeRabbit

  • New Features

    • Added asynchronous access token retrieval capability, enabling non-blocking token access in async contexts. Both standard and async client implementations now support this feature, with fallback to existing token retrieval methods when async tokens are unavailable.
  • Tests

    • Added comprehensive test coverage for token retrieval properties, including synchronous access, asynchronous retrieval paths, and OAuth-based initialization scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitaibot commentedDec 12, 2025
edited
Loading

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the@coderabbitai review command.

You can disable this status message by setting thereviews.review_status tofalse in the CodeRabbit configuration file.

Walkthrough

Two new asynchronous propertiesasync_raw_access_token are introduced to bothPipedream andAsyncPipedream classes. These properties enable non-blocking token retrieval in async contexts by awaiting an internal async token or falling back to the existing synchronous access token. Corresponding test cases validate both sync and async token retrieval paths.

Changes

Cohort / File(s)Summary
Async token property implementation
src/pipedream/pipedream.py
Addedasync_raw_access_token property toPipedream andAsyncPipedream classes for non-blocking asynchronous access token retrieval. Properties await internal async token when available, otherwise returnraw_access_token.
Test coverage for token retrieval
tests/custom/test_client.py
Added test cases for syncraw_access_token property and asyncasync_raw_access_token property retrieval paths, including OAuth flow validation withAsyncMock.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • New properties are straightforward async wrappers with fallback logic
  • Test cases follow existing patterns with minimal complexity
  • Small scope limited to token retrieval functionality

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Title check⚠️ WarningThe PR title mentions 'get_raw_access_token()' method but the actual implementation adds 'async_raw_access_token' property, not a 'get_raw_access_token()' method.Update the PR title to accurately reflect that async_raw_access_token properties were added instead of a get_raw_access_token() method.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check✅ PassedThe PR adds async token retrieval capability via async_raw_access_token property, addressing issue#238's requirement for non-blocking token access in async contexts.
Out of Scope Changes check✅ PassedAll changes are scoped to adding async token retrieval to Pipedream and AsyncPipedream classes with corresponding tests, directly addressing issue#238 requirements.
Docstring Coverage✅ PassedDocstring coverage is 87.50% which is sufficient. The required threshold is 80.00%.

Comment@coderabbitai help to get the list of available commands and usage tips.

…cking OAuth token fetchingCo-authored-by: jverce <5479513+jverce@users.noreply.github.com>
CopilotAI changed the title[WIP] Make raw_access_token async for non-blocking useAdd async get_raw_access_token() method to AsyncPipedreamDec 12, 2025
CopilotAI requested a review fromjverceDecember 12, 2025 22:41
@jverce
Copy link
Collaborator

@coderabbitai review

coderabbitai[bot] reacted with eyes emoji

@coderabbitai
Copy link

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitaicoderabbitaibot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between2be15bf and29355bb.

📒 Files selected for processing (2)
  • src/pipedream/pipedream.py (1 hunks)
  • tests/custom/test_client.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/pipedream/pipedream.py (1)
src/pipedream/core/client_wrapper.py (1)
  • _get_token (43-47)
tests/custom/test_client.py (1)
src/pipedream/pipedream.py (5)
  • AsyncPipedream (67-133)
  • Pipedream (16-64)
  • raw_access_token (60-64)
  • raw_access_token (111-120)
  • async_raw_access_token (123-133)
🪛 Ruff (0.14.8)
tests/custom/test_client.py

16-16: Possible hardcoded password assigned to argument: "access_token"

(S106)


17-17: Possible hardcoded password assigned to: "raw_access_token"

(S105)


22-22: Possible hardcoded password assigned to argument: "access_token"

(S106)


23-23: Possible hardcoded password assigned to: "raw_access_token"

(S105)


28-28: Possible hardcoded password assigned to argument: "access_token"

(S106)


30-30: Possible hardcoded password assigned to: "token"

(S105)


37-37: Possible hardcoded password assigned to argument: "client_secret"

(S106)


49-49: Possible hardcoded password assigned to: "token"

(S105)

🔇 Additional comments (6)
tests/custom/test_client.py (4)

1-6:LGTM!

The imports are appropriate for the new test cases. AsyncMock is correctly imported for mocking async token providers in the OAuth test.


14-17:LGTM!

Test correctly verifies synchronous token access for the Pipedream client.


20-23:LGTM!

Test correctly verifies the synchronous raw_access_token property on AsyncPipedream with a static token.


26-30:LGTM!

Test correctly verifies the new async_raw_access_token property with a static token. The async/await pattern is properly used.

src/pipedream/pipedream.py (2)

113-120:LGTM!

The updated docstring appropriately warns about potential blocking behavior when using OAuth and directs async application developers to the newasync_raw_access_token property.


122-133:The implementation is complete and correct.

The async property properly initializes_async_token for OAuth flows (AsyncOAuthTokenProvider.get_token) inAsyncClient.__init__, while static tokens safely fall back to the synchronousraw_access_token property (which is non-blocking for string tokens). The test assertions attests/custom/test_client.py:42 confirming_async_token is set for OAuth are valid. No naming inconsistency exists—the implementation correctly adds theasync_raw_access_token property as intended.

Comment on lines 33 to 49
asyncdeftest_async_pipedream_async_raw_access_token_with_oauth()->None:
"""Test AsyncPipedream async method with OAuth flow."""
client=AsyncPipedream(
client_id="test-client-id",
client_secret="test-client-secret",
project_id="test-project",
)

# The client should have _async_token set when using OAuth
assertclient._client_wrapper._async_tokenisnotNone

# Mock the async token provider
client._client_wrapper._async_token=AsyncMock(return_value="mocked-oauth-token")

# Test the async method
token=awaitclient.async_raw_access_token
asserttoken=="mocked-oauth-token"

Choose a reason for hiding this comment

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

⚠️ Potential issue |🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash# Search for _async_token initialization and usageecho"=== Searching for _async_token initialization ==="rg -nP --type=py'_async_token\s*='echo -e"\n=== Searching for _async_token references ==="rg -nP --type=py'_async_token' -C3echo -e"\n=== Locating AsyncClientWrapper class ==="ast-grep --pattern'class AsyncClientWrapper { $$$ }'echo -e"\n=== Searching for AsyncClientWrapper in Python files ==="rg -nP --type=py'class AsyncClientWrapper'

Repository: PipedreamHQ/pipedream-sdk-python

Length of output: 2919


🏁 Script executed:

#!/bin/bashecho"=== Checking AsyncPipedream constructor ==="rg -nP --type=py'class AsyncPipedream' -A 30echo -e"\n=== Checking how _async_token is set during initialization ==="rg -nP --type=py'async_token' -B2 -A2| head -60

Repository: PipedreamHQ/pipedream-sdk-python

Length of output: 4973


Remove the assertion on line 42 to avoid testing private implementation details.

The assertionassert client._client_wrapper._async_token is not None directly accesses a private attribute (_async_token), creating tight coupling to implementation details. Since the test verifies the actual behavior through the public API at line 48 (token = await client.async_raw_access_token), the assertion is redundant. If OAuth initialization fails, the behavioral test will catch it when attempting to retrieve the token. Removing line 42 makes the test cleaner and less dependent on internal state.

Note: Line 45 (mocking_async_token) is acceptable since there is no public setter and mocking is necessary to test the async token provider behavior.

🧰 Tools
🪛 Ruff (0.14.8)

37-37: Possible hardcoded password assigned to argument: "client_secret"

(S106)


49-49: Possible hardcoded password assigned to: "token"

(S105)

🤖 Prompt for AI Agents
In tests/custom/test_client.py around lines 33 to 49, remove the assertion thataccesses the private attribute (the line assertingclient._client_wrapper._async_token is not None) to avoid testing privateimplementation details; simply delete that assert line and keep the mock of_async_token and the behavioral await/verify of client.async_raw_access_tokenas-is.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@coderabbitaicoderabbitai[bot]coderabbitai[bot] left review comments

@jvercejverceAwaiting requested review from jverce

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Make raw_access_token async to support non-blocking use in async contexts

2 participants

@jverce

[8]ページ先頭

©2009-2025 Movatter.jp