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

Cannot import module #33

Open
serhattsnmz opened this issue Oct 31, 2019 · 1 comment
Open

Cannot import module #33

serhattsnmz opened this issue Oct 31, 2019 · 1 comment

Comments

@serhattsnmz
Copy link

I downloaded flask-sentinel by pip like:

$ pip install flask-sentinel

When I try to import module, I am getting following error:

>>> from flask.ext.sentinel import oauth
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'flask.ext'

No module named 'flask.ext'

Also I am trying the following way too and getting different error:

>>> from flask_sentinel import oauth
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\users\serhat\desktop\repos\python3-virtual\lib\site-packages\flask_sentinel\__init__.py", line 1, in <module>
    from .flask_sentinel import ResourceOwnerPasswordCredentials, oauth  # noqa
  File "c:\users\serhat\desktop\repos\python3-virtual\lib\site-packages\flask_sentinel\flask_sentinel.py", line 11, in <module>
    from . import views
  File "c:\users\serhat\desktop\repos\python3-virtual\lib\site-packages\flask_sentinel\views.py", line 11, in <module>
    from .core import oauth
  File "c:\users\serhat\desktop\repos\python3-virtual\lib\site-packages\flask_sentinel\core.py", line 10, in <module>
    from flask_oauthlib.provider import OAuth2Provider
  File "c:\users\serhat\desktop\repos\python3-virtual\lib\site-packages\flask_oauthlib\provider\__init__.py", line 12, in <module>
    from .oauth1 import OAuth1Provider, OAuth1RequestValidator
  File "c:\users\serhat\desktop\repos\python3-virtual\lib\site-packages\flask_oauthlib\provider\oauth1.py", line 21, in <module>
    from ..utils import extract_params, create_response
  File "c:\users\serhat\desktop\repos\python3-virtual\lib\site-packages\flask_oauthlib\utils.py", line 5, in <module>
    from oauthlib.common import to_unicode, bytes_type
ImportError: cannot import name 'bytes_type' from 'oauthlib.common' (c:\users\serhat\desktop\repos\python3-virtual\lib\site-packages\oauthlib\common.py)

cannot import name 'bytes_type' from 'oauthlib.common' (c:\users\serhat\desktop\repos\python3-virtual\lib\site-packages\oauthlib\common.py)
@akuma6099
Copy link

akuma6099 commented Nov 26, 2019

I just spent 2 days trying to get this to work and it was a bit of a pain. You are correct in that flask.ext.whatever has been deprecated. You should use flask_sentinel instead. Then next error is due to a change in the requests-oauthlib package. Lastly if you want to use mongodb you have to downgrade that as well. You also need a redis version < 3 otherwise you will get a 500 error when trying to get a bearer token. Do the following and you'll be able to run it.

pip install requests-oauthlib==1.1.0 flask-pymongo==0.5.2 redis==2.10.6

Adjust your config line:
app.config.from_object('settings.Config')

Add a settings.py file with your settings:

class Config(object):
    SENTINEL_MONGO_DBNAME = "REST"
    SENTINEL_MANAGEMENT_USERNAME = "user"
    SENTINEL_MANAGEMENT_PASSWORD = "password"
    SENTINEL_MONGO_HOST = "127.0.0.1"
    SENTINEL_MONGO_PORT = "27017"
    SENTINEL_MONGO_URI = "mongodb://rest:[email protected]:27017/REST"

and off you go.

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

No branches or pull requests

2 participants