pyeve / flask-sentinel

OAuth2 Server bundled as a Flask extension
Other
160 stars 43 forks source link

ResourceOwnerPasswordCredentials(app) fails with Unknown option config_prefix error #30

Open cchayden opened 6 years ago

cchayden commented 6 years ago

In pymongo 3.7.1 the MongoClient no longer accepts a keyword parameter config_prefix. This causes a failure when executing ResourceOwnerPasswordCredentials(app) I am not sure whether pymongo has a replacement for this functionality, but in any case it causes the whole system to not start up.

I subclassed ResourceOwnerPasswordCredentials and modified the init_app method to omit that parameter. Is there a more elegant solution?

Here is the stack trace:

Traceback (most recent call last):
  File "/home/cchayden/workspaces/mda/api/auth/run.py", line 56, in <module>
    ResourceOwnerPasswordCredentials(app)
  File "/home/cchayden/.virtualenvs/mongo/lib/python3.5/site-packages/flask_sentinel/flask_sentinel.py", line 22, in __init__
    self.init_app(app)
  File "/home/cchayden/.virtualenvs/mongo/lib/python3.5/site-packages/flask_sentinel/flask_sentinel.py", line 44, in init_app
    mongo.init_app(app, config_prefix='SENTINEL_MONGO')
  File "/home/cchayden/.virtualenvs/mongo/lib/python3.5/site-packages/flask_pymongo/__init__.py", line 160, in init_app
    self.cx = MongoClient(*args, **kwargs)
  File "/home/cchayden/.virtualenvs/mongo/lib/python3.5/site-packages/pymongo/mongo_client.py", line 521, in __init__
    for k, v in keyword_opts.items())
  File "/home/cchayden/.virtualenvs/mongo/lib/python3.5/site-packages/pymongo/mongo_client.py", line 521, in <genexpr>
    for k, v in keyword_opts.items())
  File "/home/cchayden/.virtualenvs/mongo/lib/python3.5/site-packages/pymongo/common.py", line 600, in validate
    value = validator(option, value)
  File "/home/cchayden/.virtualenvs/mongo/lib/python3.5/site-packages/pymongo/common.py", line 129, in raise_config_error
    raise ConfigurationError("Unknown option %s" % (key,))
pymongo.errors.ConfigurationError: Unknown option config_prefix
caiohsramos commented 6 years ago

I was having the same issue... Apparently it has something to do with the flask-pymongo version that is not compatible with Eve's most recent version. I fixed it by running:

pip install flask-pymongo==0.5.2
rmlopes commented 5 years ago

pip install flask-pymongo==0.5.2

Also, werkzeug must be < 0.14.1 and Redis < 3.

samsantiago commented 4 years ago

Trying to upgrade/use Eve 0.9.2 and I see the same issue currently. Any recent information what versions are currently needed for flask-sentinel to work with Eve 0.9.2 for flask-pymongo, werkzeug and Redis?

Traceback (most recent call last): File "run.py", line 39, in ResourceOwnerPasswordCredentials(app) File "/usr/local/lib/python3.7/site-packages/flask_sentinel/flask_sentinel.py", line 22, in init self.init_app(app) File "/usr/local/lib/python3.7/site-packages/flask_sentinel/flask_sentinel.py", line 44, in init_app mongo.init_app(app, config_prefix='SENTINEL_MONGO') File "/usr/local/lib/python3.7/site-packages/flask_pymongo/init.py", line 154, in init_app self.cx = MongoClient(*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/pymongo/mongo_client.py", line 647, in init dict(common.validate(k, v) for k, v in keyword_opts.items())) File "/usr/local/lib/python3.7/site-packages/pymongo/mongo_client.py", line 647, in dict(common.validate(k, v) for k, v in keyword_opts.items())) File "/usr/local/lib/python3.7/site-packages/pymongo/common.py", line 725, in validate value = validator(option, value) File "/usr/local/lib/python3.7/site-packages/pymongo/common.py", line 143, in raise_config_error raise ConfigurationError("Unknown option %s" % (key,))

pymongo.errors.ConfigurationError: Unknown option config_prefix