Skip to content

Commit 29355bb

Browse files
committed
Avoid changes in core module
1 parent 76400c2 commit 29355bb

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

src/pipedream/core/client_wrapper.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,3 @@ async def async_get_headers(self) -> typing.Dict[str, str]:
120120
token = await self._async_token()
121121
headers["Authorization"] = f"Bearer {token}"
122122
return headers
123-
124-
async def _async_get_token(self) -> typing.Optional[str]:
125-
if self._async_token is not None:
126-
return await self._async_token()
127-
return self._get_token()

src/pipedream/pipedream.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,20 +112,25 @@ def raw_access_token(self) -> Optional[str]:
112112
"""
113113
Returns an access token that can be used to authenticate API requests.
114114
115-
Note: When using OAuth authentication (client_id/client_secret), this property
116-
may perform blocking network operations. For async applications, prefer using
117-
the async method `get_raw_access_token()` instead.
115+
Note: When using OAuth authentication (`client_id`/`client_secret`),
116+
this property may perform blocking network operations. For async
117+
applications, prefer using the async property `async_raw_access_token`
118+
instead.
118119
"""
119120
return self._client_wrapper._get_token()
120121

121-
async def get_raw_access_token(self) -> Optional[str]:
122+
@property
123+
async def async_raw_access_token(self) -> Optional[str]:
122124
"""
123-
Asynchronously returns an access token that can be used to authenticate API requests.
125+
Asynchronously returns an access token that can be used to authenticate
126+
API requests.
124127
125-
This method is non-blocking and safe to use in async contexts such as FastAPI,
126-
Django ASGI, or any other asyncio-based application.
128+
This method is non-blocking and safe to use in async contexts such as
129+
FastAPI, Django ASGI, or any other asyncio-based application.
127130
"""
128-
return await self._client_wrapper._async_get_token()
131+
if self._client_wrapper._async_token is not None:
132+
return await self._client_wrapper._async_token()
133+
return self.raw_access_token
129134

130135

131136
def _get_base_url(environment: PipedreamEnvironment) -> str:

tests/custom/test_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ def test_async_pipedream_raw_access_token() -> None:
2323
assert client.raw_access_token == "test-token"
2424

2525

26-
async def test_async_pipedream_get_raw_access_token() -> None:
27-
"""Test AsyncPipedream async method get_raw_access_token() with access_token."""
26+
async def test_async_pipedream_async_raw_access_token() -> None:
27+
"""Test AsyncPipedream async method async_raw_access_token() with access_token."""
2828
client = AsyncPipedream(access_token="test-token", project_id="test-project")
29-
token = await client.get_raw_access_token()
29+
token = await client.async_raw_access_token
3030
assert token == "test-token"
3131

3232

33-
async def test_async_pipedream_get_raw_access_token_with_oauth() -> None:
33+
async def test_async_pipedream_async_raw_access_token_with_oauth() -> None:
3434
"""Test AsyncPipedream async method with OAuth flow."""
3535
client = AsyncPipedream(
3636
client_id="test-client-id",
@@ -45,5 +45,5 @@ async def test_async_pipedream_get_raw_access_token_with_oauth() -> None:
4545
client._client_wrapper._async_token = AsyncMock(return_value="mocked-oauth-token")
4646

4747
# Test the async method
48-
token = await client.get_raw_access_token()
48+
token = await client.async_raw_access_token
4949
assert token == "mocked-oauth-token"

0 commit comments

Comments
 (0)