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

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

Open
paselin-vf opened this issue Jan 11, 2024 · 2 comments
Assignees
Labels

Comments

@paselin-vf
Copy link

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:

  • OS: Ubuntu
  • Python Version: 3.11
  • Authlib Version: 1.3.0

Additional context

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

@insertokname
Copy link

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

@insertokname
Copy link

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

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

No branches or pull requests

3 participants