Skip to content
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

Bug in client when no access token is provided #58

Open
raphaelrpl opened this issue Aug 9, 2023 · 0 comments
Open

Bug in client when no access token is provided #58

raphaelrpl opened this issue Aug 9, 2023 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@raphaelrpl
Copy link
Contributor

There is a bug in lccs.py when a request is made to LCCS Server without property access_token.

curl https://path/to/lccs/classification_systems?access_token=token_e
    return self.svc.lccs_ws.get_system_classification()
  File "/terra_collect/terra_collect/services/lccs_ws.py", line 51, in get_system_classification
    systems = lccs_service.classification_systems
  File "/usr/local/lib/python3.7/site-packages/lccs/lccs.py", line 90, in classification_systems
    return self._get_classification_systems()
  File "/usr/local/lib/python3.7/site-packages/lccs/lccs.py", line 61, in _get_classification_systems
    data = Utils._get(url)
  File "/usr/local/lib/python3.7/site-packages/lccs/utils.py", line 40, in _get
    response.raise_for_status()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: NOT FOUND for url: http://dev-lccs-ws:5000/classification_systems&language=pt-br

The error occurs due wrong usage of URI and parameters in request session.

For example:

self._access_token = f'?access_token={access_token}' if access_token else ''

and here

url = f'{self._url}/classification_systems{self._access_token}{self._language}'

You should use something like this

params = {"language": "pt-br"}
if self.access_token:
    params["access_token"] = self.access_token

session.get(SERVICE_RESOURCE_URL, params=params)

DO NOT manually concat these parameters in URL

@raphaelrpl raphaelrpl added the bug Something isn't working label Aug 9, 2023
@raphaelrpl raphaelrpl added this to the Version 1.0.0 milestone Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants