Simple use case
Hi, I've been asked to do something seemingly simple. Create a back-end micro service that accepts a file and a Box username and uploads that file to that enterprise user's account. Since this is a back-end service there's no user interaction. I'm not seeing in the docs where this is possible. I'm also not seeing where I can upload to a specific user. Can someone point me in the right direction?
-
Hi
Welcome to the Box Community and thanks for your first post in the forum!
Thanks for providing so much detail on this! That'll help the community to figure this out!
If you don't get a response, try posting more info to clarify what you're looking for!
Be sure to read our guidelines, Subscribe to content you like, and complete your profile on the community.
-
Hi ! Thanks for your message!
That's a great question. On Box, there always has to be some sort of authorization for an app to act on a user's account. If there is user interaction (Standard Authentication), the user explicitly grants access. If there's not user interaction, the administrator of the user's enterprise must authorize the application via their admin console, which then allows access to that enterprise's users. That's Server Authentication, which is described more in detail here:
https://developer.box.com/v2.0/docs/authentication-with-jwt
And you can see more of a comparison between the two here:
https://developer.box.com/v2.0/docs/authentication
Server Authentication sounds like the best fit for your use case. As for uploading, you'll always have to specify a parent folder when you upload:
https://developer.box.com/reference#upload-a-file
And as long as your user either owns or has collaboration access to that folder, you can consider that "in" their account. Hope this helps!
Thanks,
Jason
-
One more thing! Something that might help you is the As-User header:
https://developer.box.com/reference#as-user-1
That way, once you get an enterprise token, you can simply "impersonate" a user to upload files into their account. An example is using the root folder (folder ID = 0), and just changing the As-User header to reflect which user's root folder you want.
The As-User header applies to both authorization methods, but makes more sense for standard OAuth2. The reason for that is that in Server Authentication, you have the ability to get access tokens for any user directly, so there's less need to impersonate - but, that would also increase the amount of tokens you have to manage. Using the As-User header with Server Authentication would mean you could generate just one token and change the header, vs generating a new token for every user.
サインインしてコメントを残してください。
コメント
3件のコメント