garyburgmann / drf-firebase-auth

Firebase backend to receive a user idToken and authenticate via Django REST Framework 'authentication.BaseAuthentication'. Optionally, a new local user can be created in the process.
MIT License
128 stars 62 forks source link

Incompatible with Django 4.x #40

Open quorth0n opened 2 years ago

quorth0n commented 2 years ago

Using this package with django 4.x gives the following error:

Traceback (most recent call last):
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/rest_framework/settings.py", line 177, in import_from_string
    return import_string(val)
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/django/utils/module_loading.py", line 30, in import_string
    return cached_import(module_path, class_name)
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/django/utils/module_loading.py", line 15, in cached_import
    import_module(module_path)
  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/drf_firebase_auth/authentication.py", line 11, in <module>
    from django.utils.encoding import smart_text
ImportError: cannot import name 'smart_text' from 'django.utils.encoding' (/opt/pysetup/.venv/lib/python3.10/site-packages/django/utils/encoding.py)

Smart text has been deprecated since django 3.0 and removed in 4.0. I'm willing to submit a PR that fixes this

adamduren commented 2 years ago

@garyburgmann thank you for your work on this. Any chance we can get this moving forward and a release cut? It is blocking our Django 4.0 upgrade.

garyburgmann commented 2 years ago

Hi Adam,

I do certainly need to put some time into this. I will look to pencil in some time Mon 21st and Tue 22nd to do this. Pull requests welcome.

Cheers, Gary

On 8 Mar 2022, at 1:43 am, Adam Duren @.***> wrote:

@garyburgmann https://github.com/garyburgmann thank you for your work on this. Any chance we can get this moving forward and a release cut? It is blocking our Django 4.0 upgrade.

— Reply to this email directly, view it on GitHub https://github.com/garyburgmann/drf-firebase-auth/issues/40#issuecomment-1060826591, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGIRYIS3EFCC7KVWUHS7D6TU6YPY3ANCNFSM5OPR5EKA. You are receiving this because you were mentioned.

adamduren commented 2 years ago

I believe @quorth0n has addressed the compatibility issue in PR #41

quorth0n commented 2 years ago

@garyburgmann check my PR on this issue, should be good to merge

@adamduren you can set your requirements.txt to install from my fork while we wait for a merge, pip install git+https://github.com/quorth0n/drf-firebase-auth@issue-40

Llanilek commented 1 year ago

It's a shame this hasn't yet made it into a release. Pretty vital update to keep the library current.

@garyburgmann are you still working on this project?

tarikozket commented 1 year ago

smart_text is deleted but they introduced something new called smart_str, you can map smart_text to smart_str to make old libraries work for the time being.

you can do the following in your settings file:

import django
from django.utils.encoding import smart_str

django.utils.encoding.smart_text = smart_str
garyburgmann commented 1 year ago

It's a shame this hasn't yet made it into a release. Pretty vital update to keep the library current.

@garyburgmann are you still working on this project?

Apologies all, I have been out of the Django game for a little while and been slack at maintaining this.

If anyone is interested in being a maintainer here, please ping me.

Will try to review PRs this weekend.

Llanilek commented 1 year ago

@garyburgmann happy to assist where I can with maintaining.