Skip to content

Commit 00314bf

Browse files
Merge pull request #456 from supertokens/fix/signin_up-invalid-redirect-uri-server-err
fix: server error when `redirect_uri_info` is not passed in the sign_in_up API
2 parents 32d307b + 553a621 commit 00314bf

File tree

5 files changed

+81
-13
lines changed

5 files changed

+81
-13
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
## [unreleased]
1010

11+
## [0.16.6] - 2023-10-24
12+
13+
- Fixed server error in `sign_in_up` API
14+
- There was a bug in case where the API was called with just oAuth tokens without passing the `redirect_uri_info`.
15+
1116
## [0.16.5] - 2023-10-23
1217

1318
- Relaxed constraint on `pyJWT` dependency.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070

7171
setup(
7272
name="supertokens_python",
73-
version="0.16.5",
73+
version="0.16.6",
7474
author="SuperTokens",
7575
license="Apache 2.0",
7676
author_email="[email protected]",

supertokens_python/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from __future__ import annotations
1515

1616
SUPPORTED_CDI_VERSIONS = ["3.0"]
17-
VERSION = "0.16.5"
17+
VERSION = "0.16.6"
1818
TELEMETRY = "/telemetry"
1919
USER_COUNT = "/users/count"
2020
USER_DELETE = "/user/remove"

supertokens_python/recipe/thirdparty/api/signinup.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ async def handle_sign_in_up_api(
4242
if third_party_id is None or not isinstance(third_party_id, str):
4343
raise_bad_input_exception("Please provide the thirdPartyId in request body")
4444

45-
redirect_uri_info = body.get("redirectURIInfo")
46-
oauth_tokens = body.get("oAuthTokens")
47-
48-
if redirect_uri_info is not None:
49-
if redirect_uri_info.get("redirectURIOnProviderDashboard") is None:
45+
oauth_tokens = None
46+
redirect_uri_info = None
47+
if body.get("redirectURIInfo") is not None:
48+
if body.get("redirectURIInfo").get("redirectURIOnProviderDashboard") is None:
5049
raise_bad_input_exception(
5150
"Please provide the redirectURIOnProviderDashboard in request body"
5251
)
53-
elif oauth_tokens is not None:
54-
pass # Nothing to do here
52+
redirect_uri_info = body.get("redirectURIInfo")
53+
elif body.get("oAuthTokens") is not None:
54+
oauth_tokens = body.get("oAuthTokens")
5555
else:
5656
raise_bad_input_exception(
5757
"Please provide one of redirectURIInfo or oAuthTokens in the request body"
@@ -71,15 +71,18 @@ async def handle_sign_in_up_api(
7171

7272
provider = provider_response
7373

74-
result = await api_implementation.sign_in_up_post(
75-
provider=provider,
76-
redirect_uri_info=RedirectUriInfo(
74+
if redirect_uri_info is not None:
75+
redirect_uri_info = RedirectUriInfo(
7776
redirect_uri_on_provider_dashboard=redirect_uri_info.get(
7877
"redirectURIOnProviderDashboard"
7978
),
8079
redirect_uri_query_params=redirect_uri_info.get("redirectURIQueryParams"),
8180
pkce_code_verifier=redirect_uri_info.get("pkceCodeVerifier"),
82-
),
81+
)
82+
83+
result = await api_implementation.sign_in_up_post(
84+
provider=provider,
85+
redirect_uri_info=redirect_uri_info,
8386
oauth_tokens=oauth_tokens,
8487
tenant_id=tenant_id,
8588
api_options=api_options,

tests/thirdparty/test_thirdparty.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,63 @@ async def test_signinup_works_when_validate_access_token_does_not_throw(
268268
assert res.status_code == 200
269269
assert access_token_validated is True
270270
assert res.json()["status"] == "OK"
271+
272+
273+
async def test_signinup_android_without_redirect_uri(
274+
fastapi_client: TestClient, mocker: MockerFixture
275+
):
276+
time = str(datetime.datetime.now())
277+
mocker.patch(
278+
"supertokens_python.recipe.thirdparty.providers.custom.get_supertokens_user_info_result_from_raw_user_info",
279+
return_value=UserInfo(
280+
"" + time,
281+
UserInfoEmail(f"johndoeprovidertest+{time}@supertokens.com", True),
282+
RawUserInfoFromProvider({}, {}),
283+
),
284+
)
285+
st_init_args = {
286+
**st_init_common_args,
287+
"recipe_list": [
288+
session.init(),
289+
thirdpartyemailpassword.init(
290+
providers=[
291+
ProviderInput(
292+
config=ProviderConfig(
293+
third_party_id="custom",
294+
clients=[
295+
ProviderClientConfig(
296+
client_id="test",
297+
client_secret="test-secret",
298+
scope=["profile", "email"],
299+
client_type="android",
300+
),
301+
],
302+
authorization_endpoint="https://example.com/oauth/authorize",
303+
authorization_endpoint_query_params={
304+
"response_type": "token", # Changing an existing parameter
305+
"response_mode": "form", # Adding a new parameter
306+
"scope": None, # Removing a parameter
307+
},
308+
token_endpoint="https://example.com/oauth/token",
309+
),
310+
)
311+
]
312+
),
313+
],
314+
}
315+
init(**st_init_args) # type: ignore
316+
start_st()
317+
318+
res = fastapi_client.post(
319+
"/auth/signinup",
320+
json={
321+
"thirdPartyId": "custom",
322+
"clientType": "android",
323+
"oAuthTokens": {
324+
"access_token": "accesstoken",
325+
"id_token": "idtoken",
326+
},
327+
},
328+
)
329+
assert res.status_code == 200
330+
assert res.json()["status"] == "OK"

0 commit comments

Comments
 (0)