Upgrading from BOX APIs V1 to V2 - box-api

I am working on upgrading the synchronization layer for a web application with the box account and I am in the middle of the way and have some questions:
Is there a way to get the full structure for the folders and the documents with one request? My other solution it to make multiple requests for each folder to get its contains (folders and files)
Tags APIs in V2 is not yet added, is there a certain confirmed date to have it ready? Tags is important in our application.
Authorization, I am using the same values used in API V1 as a header (Authorization: BoxAuth api_key={0}&auth_token={1}) (one system account) without the need to use the refresh token to get a new authorization token every while. Is this going to work in the future?
Is there a way to call a service or web api on our web application side every time a user tried to delete a document from box to check if this document can be deleted or not?
Thanks

1) There isn't a 1:1 equivalent of get_account_tree in V2. You'll need to make recursive GET /folders/:id/items calls in order to get the entire folder tree
2) We will be adding tags in V2 but don't have a definitive date at this point.
3) No. V1 authentication will be deprecated along with the V1 API. You'll need to port your app over to using OAuth 2.
4) You may want to check into the /events API for doing this: http://developers.box.com/docs/#events-get-events-for-a-user

Related

How do I quickly list all Google Cloud projects in an organization?

I would like to quickly list all Google Cloud projects in an organization, without AppScript folders.
gcloud projects list can be very slow. This documentation is about speeding it up, but does not show how to retrieve the Appscript folder which is used for filtering. Can that be done from the command line?
Also, gcloud projects list does not have a way to filter by organization. It seems that that is impossible as projects are not linked to their organization except through a tree of folders.
The documentation shows a way of walking the tree, apparently with Resource Manager API, which might do the job, but only pseudocode is shown. How can this be done with gcloud -- or else with Python or another language?
And if there is no way to accelerate this: How do I page through results using gcloud projects list? The documentation shows that page-size can be set, but does not show how to step through page by page (presumably by sending a page number with each command).
See also below for a reference to code I wrote that is the imperfect but best solution I could find.
Unfortunately there isn’t a native Apps Script resource available to work with Cloud Resource Manager API.
Although, it is possible to make a HTTP call directly to the Resource Manager API projects.list() endpoint with the help of UrlFetchApp service.
Alternatively, using Python as mentioned, the recommended Google APIs client library for python supports calls to Resource Manager API. You can find the specific projects.list() method documentation here.
On additional note, if you happen to use a Cloud project to generate credentials and authenticate the API call, you may want to enable Cloud Resource Manager API on your project by following this URL.
I’d also recommend submitting a new Feature Request using this template.
Here is some code that lists projects in an organization as quickly as possible. It is in Clojure, but it uses Java APIs and you can translate it easily.
Key steps
Query all accessible projects using CloudResourceManager projects(), using setQuery to accelerate the query by filtering out, for example, the hundreds of sys- projects often generated by AppScript. The query uses paging.
From the results
Accept those that are the child of the desired org
Reject those that are the child of another org.
For those that are the child of a folder, do this (concurrently, for speed): Use gcloud projects get-ancestors $PROJECT_ID to find the projects in your organization. (I don't see a way to do that in Java, and so I call the CLI.)

Google Map API key expires

I have generated a Google Map API Key using Google console and currently that has 'None' restriction. It works fine and I am able to consume Google Places API without any problem. I am using Ionic framework and my application is purely based on HTML and AngularJS (JavaScript).
Now as my key works as expected for some duration, it stops working all of a sudden after sometime. Google service returns 'UNKNOWN ERROR' as response for all calls. To resolve this I need to generate another key and without code changes everything works fine. I have used URL https://maps.googleapis.com/maps/api/js?key=AIzaSyDgM6rXXXXXXXXXXXXXXXXXXXXTA68vY5g&callback=&libraries=places and pasted it in browser and copied the content of the generated JavaScript in a file and referring it locally. Also FYI, I don't have any server side code with me.
Now I have precisely 2 questions.
Do I need to change my Google API key every week to keep it active? Or once the restriction is set to 'Android' or 'HTTPS' then the key will work as long as I want?
If I publish my app in Android store is it safe to place the Google API Key in app files (JavaScript or HTML)? Is there a better way of doing it? Google best practices says we should keep it outside root, but then how should I do it?
You might not have billing enabled on your project.
Without billing enabled you only get 1,000 free requests per 24 hour period (calculated as the sum of client-side and server-side requests).
After you enable billing you get up to 150,000 requests per 24 hour period free of charge.
It might be slightly confusing that JS API Places library usage counts against the Places API limit, but that is the case: the daily usage is calculated as the sum of client-side and server-side requests combined.

Wordpress api, getting users data

I'm currently working on an application in titanium appcelerator, alloy - where I'm pulling data from wordpress via rest api.
My problem now is that I need to get the data from the the users of the of the wordpress site. Info like name, email ect.
Anyone ever tried or know how it's done? The end tag: /users? Doesn't seems to be enough
In accordance with official documentation on WP-API docs data that you need is not accessable through standart API requests and endpoints (it is only "visible" during editing).
But you can create your own route and using internal API/hooks to get all data and return it in json format in prefered way (see Adding Endpoints section on provided before site).

Google Drive SDK, How to check if a file has been shared outside of the domain by using Permission feed

I am using Google Drive SDK for .NET. Everything is working as expected, except that whenever I get the permission feed for a particular document. I get the Id, kind, name, role, selflink and type fields on permission.
There is no mention of the email address of the user which is stopping me from recognizing by reading the permissions, whether a file has been shared inside the domain or outside of the domain.
I can't use Google Docs API to get the ACL on doc because I am writing an app for users over 200000 users and I will need speed which is provided by Google API Console.
What should I do?
Thanks
You can use the Documents List API to get the email addresses. I'm curious why you believe Drive is faster than Documents List, for most API calls they have a comparable response time.
https://developers.google.com/google-apps/documents-list/#retrieving_the_acl_for_a_document_file_or_collection
Thanks for the idea but can I use Document List API with the Service Accounts provided through API Console?
Why do I believe that Google Drive SDK is better? Because we don't have any control over Document List API where we can set QPS (Query per second) limits or not that I know of.
Secondly, with Document List API when you make request to servers, in the past I had to create a fault tollerent algorithm in such a way that if one request fails second should go after 2 seconds if that fails then make your next request after 5 seconds until 7 second delay.
So, I don't think that Document List API would be a good fit for processing documents over 200000 users everyday unless Google has changed the way their API used to behave?

API V2 - Enterprise - Create Managed User

I am evaluating box for enterprise accounts. Within version 1 docs there are Enterprise Commands such as
create_managed_user
edit_managed_user
etc
Is there V2 commands which are the same ?
Will the existing V1 Commands for these methods be deprecated ?
Updating this, since someone recently referred to it, even though this answer is pretty ancient.
Fully updated:
There is about 20% more surface area available for "Administrative use" in the V2 API, than there was in the V1 Box.com API.
Where? /users
POST to create a new one
GET /users to see all the users in the enterprise
PUT /users/ to update a specific user
GET /users/?fields=a,b,c to get specific fields you want to see, including some non default fields like their enterprise-id, their role, some permissions, etc. See the docs for users, and look for the green fields.
Where else? /groups
POST to create a new one
GET to get a list of all groups
GET /groups//memberships to get a list of all the users in a group
What else? as-user headers can let you build applications that automate processes for your users.
Of course to do all these things, you have to be an admin, granted the permissions to do these various different things.
The V2 API has some admin-level APIs, mostly under the /users endpoint (http://developers.box.com/docs/). However, many methods are still being added to the V2 API, and much of the administrative functionality is only available in the V1 API at the moment. The V2 API does not yet have equivalent method's for create_managed_user or edit_managed_user from V1.
We generally recommend that apps use the V2 API as much as possible, and include V1 calls when needed. As we add more methods to the V2 API, it's best to change your v1 calls as soon as you can.