Comments (5)
Thank you very much @ppolewicz , your solution does seem to work and I understand what's going on.
Maybe a brief mention of this in the docs would be helpful, because the tutorial only uses the InMemoryAccountInfo as I described.
Thanks again
from b2-sdk-python.
Thanks for the reply. But it's still unclear when (and how) that cache gets updated with the bucket id and bucket name.
Following the tutorial (with real keys of course):
from b2sdk.v2 import InMemoryAccountInfo, B2Api
info = B2Api.InMemoryAccountInfo()
b2_api = B2Api.B2Api(info)
b2_api.authorize_account("production", 'fake_key_id', 'fake_key')
bucket = b2_api.get_bucket_by_id('fake_bucket_id')
The last line fails with an Unauthorized: unauthorized for application key with capabilities
error.
Is there a step I'm missing?
The key that I'm using has read and write access to the files.
Thanks again
from b2-sdk-python.
Seems the source of your problem to be in:
b2-sdk-python/b2sdk/_internal/session.py
Lines 74 to 79 in aaf8569
I have to look more into this behavior, as my first instinct would be to change it, but we have a strong non-breaking changes policy.
In short, if AccountInfo is manually passed, then cache object is not automagically created for API and it is to expected to be passed in, explicitly, as you did with AccountInfo, i.e.
from b2sdk.v2 import B2Api, InMemoryAccountInfo, InMemoryCache
info = InMemoryAccountInfo()
b2_api = B2Api(
info,
cache=InMemoryCache() # Without this line Bucket-specific Key with only readFiles capability won't work
)
from b2-sdk-python.
You can use a key restricted to a bucket - in this case b2 account authorize
will pre-fill the bucket id-to-name cache and you shouldn't need list_buckets
from b2-sdk-python.
To avoid breaking changes, the change was made to yet not stable b2sdk._v3
interface, while b2sdk.v2
stays as it was, but fixed documentation of to recommend:
from b2sdk.v2 import B2Api, InMemoryAccountInfo, AuthInfoCache
info = InMemoryAccountInfo()
b2_api = B2Api(
info,
cache=AuthInfoCache(info)
)
where as in b2sdk.v3
the manual creation of AuthInfoCache
won't be required to attain the exactly same effect (i.e. having a working bucket cache).
from b2-sdk-python.
Related Issues (20)
- some directory exclusion patterns that worked in 1.21.0 don't work in 1.22.0 HOT 2
- delete_file_version needs bypassGovernance flag HOT 1
- passing compiled regex results in AttributeError HOT 2
- large file missing key ID HOT 10
- sync fails when encryption settings provider returns write mode b2sdk.v2.SSE_NONE HOT 8
- b2sdk v2 delete_bucket() throws v3.BucketIdNotFound exception
- b2sdk UploadTokenUsedConcurrently
- b2sdk.v2.SqliteAccountInfo does not raise an error when it fails to locate an account file HOT 6
- Invalid escape sequences in docstrings
- Tests no longer shipped in tarball HOT 6
- test_upload_url_concurrency not in test/ directory HOT 4
- lazy-fixture is not compatible with pytest 8 HOT 7
- Locale test fails HOT 1
- Progress Listener Test fails if tqdm is not installed HOT 1
- "TypeError: Argument of type 'Bucket' cannot be assigned to parameter of type 'Bucket' in b2sdk.v2" HOT 1
- Warnings on excluded files HOT 3
- In b2sdk-2.4.0, some files are uploaded redundantly HOT 4
- AsyncIO support HOT 5
- Error: externally-managed-environment on Ubuntu 24.04 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from b2-sdk-python.