lepture / authlib

The ultimate Python library in building OAuth, OpenID Connect clients and servers. JWS,JWE,JWK,JWA,JWT included.
https://authlib.org/
BSD 3-Clause "New" or "Revised" License
4.39k stars 436 forks source link

import importlib.metadata missing from authlib.integrations.flask_oauth2.errors.py? #617

Open paselin-vf opened 6 months ago

paselin-vf commented 6 months ago

Describe the bug

AttributeError raised when importing: from authlib.integrations.flask_oauth2 import ResourceProtector

Error Stacks

  File "/home//anaconda3/envs/taskapp/lib/python3.11/site-packages/flask_oidc/__init__.py", line 16, in <module>
    from authlib.integrations.flask_oauth2 import ResourceProtector
  File "/home//anaconda3/envs/taskapp/lib/python3.11/site-packages/authlib/integrations/flask_oauth2/__init__.py", line 4, in <module>
    from .resource_protector import (
  File "/home//anaconda3/envs/taskapp/lib/python3.11/site-packages/authlib/integrations/flask_oauth2/resource_protector.py", line 15, in <module>
    from .errors import raise_http_exception
  File "/home//anaconda3/envs/taskapp/lib/python3.11/site-packages/authlib/integrations/flask_oauth2/errors.py", line 6, in <module>
    _version = importlib.metadata.version('werkzeug').split('.')[0]
               ^^^^^^^^^^^^^^^^^^
AttributeError: module 'importlib' has no attribute 'metadata'

To Reproduce

A minimal example to reproduce the behavior: from authlib.integrations.flask_oauth2 import ResourceProtector

Expected behavior

Clean import

Environment:

Additional context

I think the simple fix is to add 'import importlib.metadata' at the top. Thanks!

insertokername commented 5 months ago

same issue here i can fix it manually by going into source and changing the import of authlib\integrations\flask_oauth2\errors.py to importlib.metadata

insertokername commented 5 months ago

update: works on earlier versions of python i installed a version of python 3.7.9 and it works like that