Login, create folder and upload file to Box account as service account - box-api

I reviewed the Box authentication documentation as well as the other StackOverflow questions but I'm still unable to find definite answer.
My client is an enterprise Box client and would like to build a company's internal web application that would login into Box.com using service/admin account and create folder and upload a file. The uploaded folder will be available to specific customer that will login into Box and upload additional files.
I created a sequence diagram to depict the same.
Would you let me know if this is a supported Box authentication model? Can the Box 2.0 Beta API Token be used to login as service account and create file/folder/share?
Thanks for your help!

There are several options that could work for you. Let me suggest the simplest one first, and if that is not sufficient, then I can suggest other ways to accomplish your goal.
You can use the regular Box authentication for your solution. To do so, simply get an API key and an auth-token for your application. Then, after you have uploaded your file, use the V2 API to create a shared link for your file. You can email that shared link to the client, and they can use the link to access the file.

there has been new developments since this question was posted, and now it's possible to use JWT (JSON Web Token) and Box Developers Edition to access Box.
If you create a developer account you will be able to create App users and login using an enterprise id and a private key file. Check out the docs for more information: Box Developer Edition
Additonally, boxsdk comes with support for Box Developer Edition

Related

Where can I find my Enterprise ID for Box API?

I'm using the Box API SDK for .Net, and trying to set it up to use JSON Web Tokens instead of OAuth2.
When I instantiate the BoxConfig object I need to provide the Enterprise ID:
var config = new BoxConfig( clientId, clientSecret, enterpriseId, jwtPrivateKey, jwtPrivateKeyPassword, jwtPublicKeyId );
Seeing some conflicting information:
The GitHub page for the Box Java SDK says the Enterprise ID is
on the developer console, but I don't see it there.
The Box API help page for App Auth says it's in the Admin
Console, but I don't see it there either.
Can someone point me to where, specifically, I could find the Enterprise ID?
You can find the Enterprise ID by going to the Admin Console -> Click the gear in the top right -> Click Business Settings (It may say Enterprise Settings or Elite Settings based on the account level). Under the Account Info tab you can see your Enterprise ID.
You can also get directly to that page by going to
https://www.box.com/master/settings while logged into the account. Note that only enterprise admins / co-admins with sufficient permissions will have access to that page, otherwise it will redirect to the account settings. In this case, you would need to contact your enterprise admin to get this Enterprise ID.
It appears that the Enterprise ID is embedded on most pages, even the /files page. It can be accessed by opening the browser's console and entering in window.initialConfig["enterpriseId"] or console.log(window.initialConfig["enterpriseId"]);.
Even though that will give you the Enterprise ID the application will still need to be approved by an Enterprise Admin.
You can find this in the Developer Console for your app under "Configuration" > "App Settings" where you will see a JSON representation of your App Settings JSON file that you can also download. The Enterprise ID is the enterpriseID property.

How can i share a wirecloud marketplace between users

I built some widgets and uploaded on my local marketplace, is there a way to share that?
And better is it possible to share a Mashup (the widget composition) without giving the
possibility to wiring to the user?
I mean the user should use an application layout without change anything.
You can make public your workspaces/dashboards following the steps documented in the user guide. Only the owner of a workspace will be able to modify it. I think this is what are you searching for.
Another option is to create a packaged mashup using the "Upload to my resources" option in the editor view:
Take a look to the "Advanced" tab, where you can block widgets (make them unremovable), block connections (make wiring connections unremovable) and embed used widgets/operator (by default packaged mashups depends on the user having installed all the required widgets/operators. This way you can distribute the widgets and operators used by the mashup in the same package).
However, take into account that this method is meant for sharing mashup templates, the user will always be able to add additional widgets and create new connections in the wiring view.
Once packaged, mashups/dashboards (and widgets and operators) can be uploaded to a WStore server (e.g. to the Store portal provided on FIWARE Lab) for sharing them with other users. The steps for making this is also described in the WireCloud's user guide.
I have the problem, revisited.
I have set up a working Marketplace instance (v2.3) but am unable to integrate it with Wirecloud. The marketplace is correctly registered but all the requests i am making to this Marketplace are throwing 502 error, even though i am actually able to see some results when querying the Marketplace server through a browser.
Indicatively, i can issue a GET command at http://:8080/FiwareMarketplace/v1/registration/stores/ and get an answer, but Wirecloud's internal APIs return a 502 (Bad Gateway).
Any idea on what might have gone wrong?
PS: This happens for WC v0.6.5. When upgrading to a newer (Beta) version of WC, everything seems to be performing as expected, i.e. the marketplace is correctly inserted and the stores are correctly retrieved and processed.

Can I use the Box API to create a secure online upload only web form?

Is it possible to use the Box.com API to allow users of my website to upload files via an online form, without being able to edit or see other files I have currently online? For example, hardcoding user credentials in a script with "upload only" access.
Is this possible? And if so how can I implement this?
Box has an upload widget that you can easily embed into your site to accept files.
If you are looking to do this programmatically, then you can use an SDK or upload method to upload a file from a form. For authentication, you can either ask to authenticate the user with their Box account or use a system level user that belongs to you.

Google API Service Accounts with Drive SDK

I'm looking for some clarification on accessing Google docs/Drive SDK via a Service Account.
I have everything set up in the API Console and I can successfully generate an access token via the JWT process and indeed I can issue requests to either drive SDK or the Docs List API to get a listing of documents. However, the document listing is always empty, I was expecting to see all the documents in my Google Drive. I am obviously not understanding fully what a service account gives you. If I upload a document via the Service Account then it does show up correctly, but is not visible in my Google Drive, it's as if the Service Account is a totally separate black box.
The reason I want to use Service Accounts is that I have a service running that needs to upload documents to various clients Google Docs accounts, without them having to go through the OAuth dance as there will be no UI interaction at all. Is this possible with Google docs. I was hoping that they could just send my the client_email and the certificate with the private key and I would be able to upload documents to that account.
Many thanks for your consideration
-Marshall
Not sure whether you need the answer anymore, but I just faced with the same issue, came to this post. Found one solution which works in my case, so sharing with everyone here.
The only integration point towards GoogleDrive in my case is document listing.
When I first created my service account, it didn't work as well (just empty list all the time).
What did I do to fix it:
Go to MyDrive UI https://drive.google.com/#my-drive
Checked all the documents I want to see on my website
In the top menu clicked "More"->"Share..."->"Share..."
In "Add people" section (new window "Sharing settings (N items)") I added service account email (format is "XXXXXX##developer.gserviceaccount.com")
Run document listing once again and got it working.

I am facing "The authenticated user has not installed the app with client id" error even after installing the app [duplicate]

I'm working on a Google Drive interface for Emacs. The concept is that Emacs could provide a platform-agnostic way to load, modify and save text documents stored in Google Drive. I've registered my app and can authenticate with OAuth2 and get a file listing with the Docs List API, but when I try to execute an Insert with the Google Drive API, I see an error:
"The authenticated user has not installed the app with client id ..."
Reading further, it seems I need to publish my Emacs application in the Chrome Web Store to get access to the Drive API. That doesn't make sense to me...I noticed that there is a FUSE project in development for Google Drive, which suggests that native development is possible. When I skimmed the code, however, I didn't see a Chrome Web Store component to getting it working.
Am I trying to misuse the API, or is there an route to make this work that makes more sense?
EDIT:
According to Ali Afshar, of the Google Drive team, installation is no longer required to use this API. So what follows may no longer be relevant, but will be left for historical purposes.
So, first off the API does not support application development in the sense that we are both doing it, I wouldn't use the word native though. The good news is I have been doing some research and Google Drive is really just a rebranding of Google Docs. So the Google Docs API could be a good choice as well for the same purposes.
Anyway, here's the steps to solve the error: "The authenticated user has not installed the app with client id ..." Which is a 403 error, for the sake of this answer. These steps assume you have set up an app in the chrome web store as is required, and installed it. I am working on my local machine too, with my project: http://github.com/tom-dignan/gdrive-cli which I have gotten past this error, so I think you should keep plugging away at your emacs version, because I think we can make this work.
a. Open the Google APIs console.
b. Confirm you've already enabled the apis under "API Access" both the API and SDK for Google drive should be enabled. There you get your client secrets/api keys and such. I am almost positive you've done this already, so go ahead to C. (this is here for others who may have missed it)
c. In the left navigation bar, under "Drive SDK" you will need to do the following:
Add a "Support URL" (required)
Add at least a small 16x16 application icon (required)
Add "OAuth Client ID (Required)" under Drive Integration (I was just tinkering and this seems to be the key field.)
Add "Open URL (Required) URL to open for your app from the google drive UI."
Check off "Multiple File Support"
Add some MIME types and file extensions, "text/plain", and txt for example
Add the the auth scopes:
https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/userinfo.profile
Don't bother trying to add the auth scopes for Google Docs here, because it won't work. Google does not want us to use it that way because files that drive apps create should be private to that app. Integration with Google Docs will have to be separate.
Now I know you must be thinking "why do I have to add some of these..." It's because the form makes them required fields. In mine, I put a couple URLs that point to static HTML pages.
Once you've done the above, clean up your state and reinstall your chrome app. Then try your code again, and it should stop giving you a 403.