Skip to content

Commit

Permalink
Change from query param to fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
DillonOLeary committed Jan 24, 2025
1 parent 5f3b599 commit e7c0729
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions data-pipeline/data_pipeline/aisr.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,13 @@ def _get_code_from_response(response: requests.Response) -> str:
"""
location = response.headers.get("Location")
if location:
query_dict = parse_qs(urlparse(location).query)
return query_dict["code"][0]
parsed_url = urlparse(location)
fragment = parsed_url.fragment
fragment_dict = parse_qs(fragment)
code_list = fragment_dict.get("code")
if code_list:
return code_list[0]
raise CodeNotFoundError("Code not found in response fragment.")
raise CodeNotFoundError("Code not found in response Location header.")


Expand Down
2 changes: 1 addition & 1 deletion data-pipeline/tests/unit/test_aisr.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_extract_code_from_auth_response_headers(fastapi_server):
test_realm_url = f"{fastapi_server}/auth/realms/idepc-aisr-realm"
mock_response = Mock()
mock_response.status_code = 302
mock_response.headers = {"Location": f"{test_realm_url}?code=test_code"}
mock_response.headers = {"Location": f"{test_realm_url}#code=test_code"}

code = _get_code_from_response(mock_response)

Expand Down

0 comments on commit e7c0729

Please sign in to comment.