-
Notifications
You must be signed in to change notification settings - Fork 185
docs: add an example how to check connection credentials #269
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #269 +/- ##
=======================================
Coverage 90.52% 90.52%
=======================================
Files 39 39
Lines 3355 3355
=======================================
Hits 3037 3037
Misses 318 318 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the current InfluxDB API is no possibility to ask for write / read rights for a given bucket… Workaround with an empty lineprotocol and empty query can be a temporary solution. InfluxDB API should be improved.
Agreed that this should be given at the API level. However, having an example seems like a good workaround for now. Was there a bug report against influxdb make the API changes or an official response regarding adding this feature? |
@powersj We have discussed this issue with Ryan but with no clear outcome https://influxdata.slack.com/archives/C5BSZ026L/p1594730843212900. |
It looks like the Authorizaitons API pointed about in the slack comment only works when the user has at least read access to the authorizations service, which I expect most users will not have. In fact, in most cases, I would expect a user to have a read or read-write token specifically for a bucket only, so this will not work. @rhajek, was there a concern with the include the example for now? |
0568e2e
to
da70429
Compare
"""Check that the credentials has permission to write into the Bucket""" | ||
print("> Checking credentials for write ...", end=" ") | ||
try: | ||
client.write_api(write_options=SYNCHRONOUS).write(bucket, org, b"") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this tested on both OSS and Cloud2 ? I can imagine that the can be different order of 400 and 404 checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested the latest version of InfluxDB v2.3.0+SNAPSHOT.090f681737 and InfluxDB Cloud 2. There is little inconsistency between query check that always fail with 404 (could not find bucket) but the write can fail with 403 or 404.
403 - bucket exists but you don't have a write permission
Reason: Forbidden
HTTP response body: {"code":"forbidden","message":"insufficient permissions for write"}
404 - bucket does not exists
Reason: Not Found
HTTP response body: {"code":"not found","message":"bucket "xxx" not found"}
da70429
to
5bbe48b
Compare
Closes #131
Proposed Changes
Added an example how to check if the credentials has sufficient permission to query/write.
Checklist
pytest tests
completes successfully