How to upload a file a folder shared by other




  • Jason

    Hey  , I think you might be running into an odd part of the as-user design, where you can't actually take actions on content external to your enterprise when you impersonate a managed user with "as-user". This is the same reason why you only see "External folder" in your admin console screenshot. 


    In terms of Box's product offerings, we have two ways for apps to impersonate users - one is as-user, which is designed to reflect one user (one access token) impersonating another user. The second way is generating a token for the user directly, which a flow specific to JWT auth. This is the flow you want, and you can do this in python with this excerpt:


    You'll know you've done it right when you're able to return information about the external folders via the API.


    Hope that helps,


    コメントアクション パーマリンク
  • JonathanEdward

    Hi Jason,

    I actually passed through document several times but cant get the idea. Now seem OK will few lines of code.


    auth = JWTAuth.from_settings_file(r'path-to-config-json')
    client = Client(auth)
    user_client = Client(auth)
    file_path = r'PATH-TO-UPLOAD-FILE'
    box_file = user_client.folder('ROOT-FOLDER-ID').upload(file_path)

    Thank you very much.

    コメントアクション パーマリンク