Skip to content

feat(api): make redirect_uri optional #298

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/finch/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def get_access_token(
self,
code: str,
*,
redirect_uri: str,
redirect_uri: str | None = None,
) -> str:
"""Returns an access token for the Finch API given an authorization code.

Expand Down Expand Up @@ -657,7 +657,7 @@ async def get_access_token(
self,
code: str,
*,
redirect_uri: str,
redirect_uri: str | None = None,
) -> str:
"""Returns an access token for the Finch API given an authorization code.

Expand Down
4 changes: 2 additions & 2 deletions src/finch/resources/access_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def create(
self,
*,
code: str,
redirect_uri: str,
client_id: str | NotGiven = NOT_GIVEN,
client_secret: str | NotGiven = NOT_GIVEN,
redirect_uri: str | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -98,9 +98,9 @@ async def create(
self,
*,
code: str,
redirect_uri: str,
client_id: str | NotGiven = NOT_GIVEN,
client_secret: str | NotGiven = NOT_GIVEN,
redirect_uri: str | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down
4 changes: 2 additions & 2 deletions src/finch/types/access_token_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
class AccessTokenCreateParams(TypedDict, total=False):
code: Required[str]

redirect_uri: Required[str]

client_id: str

client_secret: str

redirect_uri: str
10 changes: 2 additions & 8 deletions tests/api_resources/test_access_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,23 @@ class TestAccessTokens:
def test_method_create(self, client: Finch) -> None:
access_token = client.access_tokens.create(
code="<your_authorization_code>",
redirect_uri="https://example.com",
)
assert_matches_type(CreateAccessTokenResponse, access_token, path=["response"])

@parametrize
def test_method_create_with_all_params(self, client: Finch) -> None:
access_token = client.access_tokens.create(
code="<your_authorization_code>",
redirect_uri="https://example.com",
client_id="<your_client_id>",
client_secret="<your_client_secret>",
redirect_uri="https://example.com",
)
assert_matches_type(CreateAccessTokenResponse, access_token, path=["response"])

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

assert response.is_closed is True
Expand All @@ -51,7 +49,6 @@ def test_raw_response_create(self, client: Finch) -> None:
def test_streaming_response_create(self, client: Finch) -> None:
with client.access_tokens.with_streaming_response.create(
code="<your_authorization_code>",
redirect_uri="https://example.com",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -69,25 +66,23 @@ class TestAsyncAccessTokens:
async def test_method_create(self, async_client: AsyncFinch) -> None:
access_token = await async_client.access_tokens.create(
code="<your_authorization_code>",
redirect_uri="https://example.com",
)
assert_matches_type(CreateAccessTokenResponse, access_token, path=["response"])

@parametrize
async def test_method_create_with_all_params(self, async_client: AsyncFinch) -> None:
access_token = await async_client.access_tokens.create(
code="<your_authorization_code>",
redirect_uri="https://example.com",
client_id="<your_client_id>",
client_secret="<your_client_secret>",
redirect_uri="https://example.com",
)
assert_matches_type(CreateAccessTokenResponse, access_token, path=["response"])

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

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