Welcome to the new Box Support website. Check out all the details here on what’s changed.

Download files from shared folder (python)

New post

Comments

3 comments

  • Denitsa Yoncheva

    Hi! Did you figure this out? I've been stuck on the exact same issue.

    1
    Comment actions Permalink
  • Ed Baker

    Hey There,

    Yes I did... here's a snippet just for you..

     

    def download_files_from_box():

    log.info('Looking for new files to download from box')

    p_key_path = os.path.join("PATH TO YOUR SSH KEY")

    box_client_id = os.getenv("BOXCOM_CLIENT_ID")
    box_client_secret = os.getenv("BOXCOM_CLIENT_SECRET")
    box_user_id = os.getenv("BOXCOM_USER_ID")
    box_enterprise_id = os.getenv("BOXCOM_ENTERPRISE_ID")
    box_passphrase = os.getenv("BOXCOM_PASSPHRASE")

    auth = JWTAuth(
    client_id=box_client_id,
    client_secret=box_client_secret,
    user=box_user_id,
    jwt_key_id="YOURKEY",
    rsa_private_key_file_sys_path=p_key_path,
    rsa_private_key_passphrase=box_passphrase,
    enterprise_id=box_enterprise_id
    )

    auth.authenticate_user()
    user_client = Client(auth)

    # The only collection you can have is Favourites. The folder that
    # has been shared with us has been added as a favourite on our side.

    favourites_id = None
    collections = user_client.collections()
    for collection in collections:
    if collection.name == 'Favorites':
    favourites_id = collection.id

    # Grab a list of available files to download

    bulk_data_folder_id = None
    file_id_list = []
    if favourites_id:

    items = user_client.collection(collection_id=favourites_id).get_items()
    for item in items:

    if item.name == 'NAME OF YOUR FOLDER':
    bulk_data_folder_id = item.id
    1
    Comment actions Permalink
  • Sudharsana Rajasekaran

    Did you resolve this issue? I have stuck in the same place

    0
    Comment actions Permalink

Post is closed for comments.