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

Addressing URL Flexibility in OpenStreetMap and others apps base in OSM software #893

Open
Rub21 opened this issue Mar 15, 2024 · 1 comment

Comments

@Rub21
Copy link

Rub21 commented Mar 15, 2024

There are some initiatives that use OpenStreetMap software, such as OpenHistoricalMap. This module has been used by OSMCha, which is part of the OpenStreetMap and OpenHistoricalMap ecosystem. However, since the URL is hardcoded only for OSM.

https://github.com/python-social-auth/social-core/blob/master/social_core/backends/openstreetmap.py#L43

I am facing some errors when I log in using OpenHistoricalMap. Could the URLs be passed in an environment variable, or could there be an option to do that?

Internal Server Error: /api/v1/social-auth/
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/social_core/utils.py", line 251, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/social_core/backends/oauth.py", line 191, in do_auth
    data = self.user_data(access_token)
  File "/usr/local/lib/python3.10/site-packages/social_core/backends/openstreetmap.py", line 40, in user_data
    response = self.oauth_request(
  File "/usr/local/lib/python3.10/site-packages/social_core/backends/oauth.py", line 298, in oauth_request
    return self.request(url, method=method, params=params,
  File "/usr/local/lib/python3.10/site-packages/social_core/backends/base.py", line 234, in request
    response.raise_for_status()
  File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.openstreetmap.org/api/0.6/user/details

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.10/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.10/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.10/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/rest_framework/views.py", line 505, in dispatch
    response = self.handle_exception(exc)
  File "/usr/local/lib/python3.10/site-packages/rest_framework/views.py", line 465, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/usr/local/lib/python3.10/site-packages/rest_framework/views.py", line 476, in raise_uncaught_exception
    raise exc
  File "/usr/local/lib/python3.10/site-packages/rest_framework/views.py", line 502, in dispatch
    response = handler(request, *args, **kwargs)
  File "/app/osmchadjango/users/views.py", line 125, in post
    return Response(self.get_user_token(request, access_token))
  File "/app/osmchadjango/users/views.py", line 100, in get_user_token
    user = backend.do_auth(access_token, user=authed_user)
  File "/usr/local/lib/python3.10/site-packages/social_core/utils.py", line 256, in wrapper
    raise AuthForbidden(args[0])

cc. @willemarcel

@mmd-osm
Copy link
Contributor

mmd-osm commented Mar 24, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants