flask-sentinel
                                
                                
                                
                                    flask-sentinel copied to clipboard
                            
                            
                            
                        Cannot import module
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)
                                    
                                    
                                    
                                
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.