b2-sdk-python icon indicating copy to clipboard operation
b2-sdk-python copied to clipboard

b2sdk with InMemoryAccountInfo not successfully reauthenticating after authorizationToken expires

Open anderoonies opened this issue 5 months ago • 3 comments

I'm using https://github.com/ehossack/django-backblaze-b2 as a storage backend, which uses b2sdk to store files in a backblaze bucket.

Around 24 hours after deployment, I see frequent errors: unauthorized for application key with capabilities 'readFiles,listBuckets,shareFiles,listFiles,readBuckets,writeFiles,deleteFiles', restricted to bucket <bucket-name>. My understanding is the authorizationToken has expired and isn't being refreshed.

django-backblaze-b2 instantiates a B2Api, authorizes the account, then doesn't interact with the authentication lifecycle at all, leaving that up to b2sdk. I believe these errors are related to b2sdk, and not django-backblaze-b2.

With these errors, I see the following two requests:

POST https://api.backblazeb2.com/b2api/v2/b2_authorize_account 200
HEAD https://<realm>/file/<path> 401

This leads me to believe that the _reauthorization_loop method is running to attempt to update the authorizationToken, then failing.

Unfortunately I can't replicate this in an environment where I can step through the error, since it requires waiting 24 hours for the authorizationToken to expire.

anderoonies avatar Sep 05 '24 23:09 anderoonies