How to download files from a shared folder
RéponduHi,
I need to download all the files in
https://app.box.com/s/rf6p81j3o507e8c5saywtlc1p91f8po9
I cannot download it through the browser because the files are > 150 GB. Thus, I want to create a script that downloads the files one by one.
To do so, I signed up for Box, and created a Custom App. On the 'purpose' drop-down menu, I selected 'other'. Next, I selected 'server authentication (with JWT)'. I then navigated to the configuration tab and added clicked 'Genereate a Public/Private Keypair', which downloaded a file named 0_XXXXXenv_config.json where the X's are random digits/characters. I renamed this file to config.json and then tried to run:
from boxsdk import JWTAuth, Client
auth = JWTAuth.from_settings_file('config.json')
client = Client(auth)
auth.authenticate_instance()
shared_folder = client.get_shared_item("https://app.box.com/s/rf6p81j3o507e8c5saywtlc1p91f8po9")
for item in shared_folder.get_items(limit=1000):
client.file(file_id=item.id).download_to(item.name)
break
but I get:
boxsdk.exception.BoxOAuthException:
Message: Please check the 'sub' claim. The 'sub' specified is invalid.
Status: 400
URL: https://api.box.com/oauth2/token
Method: POST
Headers: {'Date': 'Tue, 23 Apr 2024 08:49:18 GMT', 'Content-Type': 'application/json', 'Strict-Transport-Security': 'max-age=31536000', 'Set-Cookie': 'box_visitor_id=6627760e46a336.78777513; expires=Wed, 23-Apr-2025 08:49:18 GMT; Max-Age=31536000; path=/; domain=.box.com; secure; SameSite=None, bv=DSYS-1179; expires=Tue, 30-Apr-2024 08:49:18 GMT; Max-Age=604800; path=/; domain=.app.box.com; secure, cn=4; expires=Wed, 23-Apr-2025 08:49:18 GMT; Max-Age=31536000; path=/; domain=.app.box.com; secure, site_preference=desktop; path=/; domain=.box.com; secure', 'Cache-Control': 'no-store', 'Via': '1.1 google', 'Alt-Svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000', 'Transfer-Encoding': 'chunked'}
I cannot list the files, let alone download them. What am I doing wrong?
-
Hi Travis,
Welcome to Box Community and glad to assist!
We suggest that you seek advice from our Developer team through forum.box.com.
Thanks for posting!
Vous devez vous connecter pour laisser un commentaire.
Commentaires
1 commentaire