1

I use Flask and Flask-Pymongo

from flask_pymongo import PyMongo
user = PyMongo(app, uri='mongodb://username:password@192.168.88.29:27018/user')

pymongo.errors.OperationFailure: Authentication failed.

But using Pymongo with same mongodb uri then work.

import pymongo
db = pymongo.MongoClient('mongodb://username:password@192.168.88.29:27018')
pakachu
  • 77
  • 1
  • 1
  • 13
  • Okay. So take a look at those two URI examples and see if you can work out what the difference is. One thing clearly stands out, and if you actually searched for previous questions like yours then the solution will point to that very same difference. – Neil Lunn Nov 14 '18 at 07:19
  • flask_pymongo needs specific dbnames so '/user' in it. it is same pymongo.MongoClient('mongodb://username:password@192.168.88.29:27018')['user'] – pakachu Nov 14 '18 at 07:24
  • 1
    i posts because of auth problem. when I use no auth mode. flask-pymongo works. – pakachu Nov 14 '18 at 07:26
  • [`authSource`](https://docs.mongodb.com/manual/reference/connection-string/#urioption.authSource) It's always been there and this is a case where you use it. – Neil Lunn Nov 14 '18 at 07:28
  • Thank you, authSource is work. – pakachu Nov 14 '18 at 08:18

0 Answers0