Skip to content

Commit 8d42399

Browse files
feat(api): make redirect_uri optional (#298)
1 parent 6e94884 commit 8d42399

File tree

4 files changed

+8
-14
lines changed

4 files changed

+8
-14
lines changed

src/finch/_client.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def get_access_token(
305305
self,
306306
code: str,
307307
*,
308-
redirect_uri: str,
308+
redirect_uri: str | None = None,
309309
) -> str:
310310
"""Returns an access token for the Finch API given an authorization code.
311311
@@ -657,7 +657,7 @@ async def get_access_token(
657657
self,
658658
code: str,
659659
*,
660-
redirect_uri: str,
660+
redirect_uri: str | None = None,
661661
) -> str:
662662
"""Returns an access token for the Finch API given an authorization code.
663663

src/finch/resources/access_tokens.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ def create(
3131
self,
3232
*,
3333
code: str,
34-
redirect_uri: str,
3534
client_id: str | NotGiven = NOT_GIVEN,
3635
client_secret: str | NotGiven = NOT_GIVEN,
36+
redirect_uri: str | NotGiven = NOT_GIVEN,
3737
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
3838
# The extra values given here take precedence over values defined on the client or passed to this method.
3939
extra_headers: Headers | None = None,
@@ -98,9 +98,9 @@ async def create(
9898
self,
9999
*,
100100
code: str,
101-
redirect_uri: str,
102101
client_id: str | NotGiven = NOT_GIVEN,
103102
client_secret: str | NotGiven = NOT_GIVEN,
103+
redirect_uri: str | NotGiven = NOT_GIVEN,
104104
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
105105
# The extra values given here take precedence over values defined on the client or passed to this method.
106106
extra_headers: Headers | None = None,

src/finch/types/access_token_create_params.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
class AccessTokenCreateParams(TypedDict, total=False):
1111
code: Required[str]
1212

13-
redirect_uri: Required[str]
14-
1513
client_id: str
1614

1715
client_secret: str
16+
17+
redirect_uri: str

tests/api_resources/test_access_tokens.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,23 @@ class TestAccessTokens:
2121
def test_method_create(self, client: Finch) -> None:
2222
access_token = client.access_tokens.create(
2323
code="<your_authorization_code>",
24-
redirect_uri="https://example.com",
2524
)
2625
assert_matches_type(CreateAccessTokenResponse, access_token, path=["response"])
2726

2827
@parametrize
2928
def test_method_create_with_all_params(self, client: Finch) -> None:
3029
access_token = client.access_tokens.create(
3130
code="<your_authorization_code>",
32-
redirect_uri="https://example.com",
3331
client_id="<your_client_id>",
3432
client_secret="<your_client_secret>",
33+
redirect_uri="https://example.com",
3534
)
3635
assert_matches_type(CreateAccessTokenResponse, access_token, path=["response"])
3736

3837
@parametrize
3938
def test_raw_response_create(self, client: Finch) -> None:
4039
response = client.access_tokens.with_raw_response.create(
4140
code="<your_authorization_code>",
42-
redirect_uri="https://example.com",
4341
)
4442

4543
assert response.is_closed is True
@@ -51,7 +49,6 @@ def test_raw_response_create(self, client: Finch) -> None:
5149
def test_streaming_response_create(self, client: Finch) -> None:
5250
with client.access_tokens.with_streaming_response.create(
5351
code="<your_authorization_code>",
54-
redirect_uri="https://example.com",
5552
) as response:
5653
assert not response.is_closed
5754
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -69,25 +66,23 @@ class TestAsyncAccessTokens:
6966
async def test_method_create(self, async_client: AsyncFinch) -> None:
7067
access_token = await async_client.access_tokens.create(
7168
code="<your_authorization_code>",
72-
redirect_uri="https://example.com",
7369
)
7470
assert_matches_type(CreateAccessTokenResponse, access_token, path=["response"])
7571

7672
@parametrize
7773
async def test_method_create_with_all_params(self, async_client: AsyncFinch) -> None:
7874
access_token = await async_client.access_tokens.create(
7975
code="<your_authorization_code>",
80-
redirect_uri="https://example.com",
8176
client_id="<your_client_id>",
8277
client_secret="<your_client_secret>",
78+
redirect_uri="https://example.com",
8379
)
8480
assert_matches_type(CreateAccessTokenResponse, access_token, path=["response"])
8581

8682
@parametrize
8783
async def test_raw_response_create(self, async_client: AsyncFinch) -> None:
8884
response = await async_client.access_tokens.with_raw_response.create(
8985
code="<your_authorization_code>",
90-
redirect_uri="https://example.com",
9186
)
9287

9388
assert response.is_closed is True
@@ -99,7 +94,6 @@ async def test_raw_response_create(self, async_client: AsyncFinch) -> None:
9994
async def test_streaming_response_create(self, async_client: AsyncFinch) -> None:
10095
async with async_client.access_tokens.with_streaming_response.create(
10196
code="<your_authorization_code>",
102-
redirect_uri="https://example.com",
10397
) as response:
10498
assert not response.is_closed
10599
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

0 commit comments

Comments
 (0)