fastapi
fastapi copied to clipboard
[docs] PasswordAuthenticator is moved from couchbase.cluster in couchbase 4.0.3
First Check
- [X] I added a very descriptive title to this issue.
- [X] I used the GitHub search to find a similar issue and didn't find it.
- [X] I searched the FastAPI documentation, with the integrated search.
- [X] I already searched in Google "How to X in FastAPI" and didn't find any information.
- [X] I already read and followed all the tutorial in the docs and didn't find an answer.
- [X] I already checked if it is not related to FastAPI but to Pydantic.
- [X] I already checked if it is not related to FastAPI but to Swagger UI.
- [X] I already checked if it is not related to FastAPI but to ReDoc.
Commit to Help
- [X] I commit to help with one of those options 👆
Example Code
from couchbase.cluster import Cluster, PasswordAuthenticator
def get_bucket():
cluster = Cluster(...)
authenticator = PasswordAuthenticator("username", "password")
...
Description
This is the example code from Document: https://fastapi.tiangolo.com/advanced/nosql-databases/
As described in title, the code can not found PasswordAuthenticator from couchbase.cluster
I tried to solve this, and I found something at repository by couchbase:
from couchbase.auth import PasswordAuthenticator
also you can see this in here: https://github.com/couchbase/couchbase-python-client/blob/64be5a03d83dbcb60fa8931621700cd867bb892f/couchbase/tests/connection_t.py#L22
I think this belongs with some changes in couchbase 4.0.0.
So, the document should be updated or needs to notify the version of couchbase that is under 4.0.x
Operating System
Windows
Operating System Details
No response
FastAPI Version
0.79.0
Python Version
Python 3.8.3
Additional Context
No response
Good catch! You'd be able to give a PR?
Well, I will have a try but I'm not sure I can :/
I think the example code will be updated to, (in couchbase 3.2.0+)
from couchbase.cluster import ClusterOptions
from couchbase.auth import PasswordAuthenticator
cluster = Cluster(
"couchbase://couchbasehost:8091?fetch_mutation_tokens=1&operation_timeout=30&n1ql_timeout=300",
+ ClusterOptions(PasswordAuthenticator("username", "password"))
)
- authenticator = PasswordAuthenticator("username", "password")
- cluster.authenticate(authenticator)