Google Team Drives have a limit of 400 000 files, I would like to know how many elements have been uploaded to a particular Drive in order to get the percentage value that the Organization Admin can see from https://admin.google.com.
I cannot find any API endpoint for this value, is there a way to calculate this limit?
Answer:
There is no endpoint which gives you this, so you would have to make a files: list call for each Drive and calculate this locally.
Example:
First, you will need to make a call to drives: list in order to get a list of all the shared Drives you are a member of:
curl \
'https://www.googleapis.com/drive/v3/drives
?fields=drives%2Fid
&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
Here, the field drives/id is used to just get a list of IDs.
You can then loop through each ID with files: list to get a list of the files in that Drive:
curl \
'https://www.googleapis.com/drive/v3/files
?corpora=drive
&driveId=[YOUR_DRIVE_ID]
&includeItemsFromAllDrives=true
&pageSize=1000
&supportsAllDrives=true
&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
In this response, you may get a nextPageToken parameter. This means that there are more than 1000 files in the Drive, and so you will need to make subsequent requests, containing this page token, until you get a response without one:
curl \
'https://www.googleapis.com/drive/v3/files
?corpora=drive
&driveId=[YOUR_DRIVE_ID] &includeItemsFromAllDrives=true
&pageSize=1000
&pageToken=[NEXT_PAGE_TOKEN]
&supportsAllDrives=true
&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
Making sure to total the number of returned results for each request.
With this of how many files are in each Shared Drive, you can calculate the percentage of the total files used per Drive mathematically:
(no_of_files_in_drive / 400000) * 100
Feature Request:
You can however let Google know that this is a feature that is important for access to their APIs, and that you would like to request they implement it.
Google's Issue Tracker is a place for developers to report issues and make feature requests for their development services, I'd urge you to make a feature request there. The best component to file this under would be the Google Drive component, with the Feature Request template.
References:
Drives: list | Google Drive API | Google Developers
Files: list | Google Drive API | Google Developers
Related
I am trying to use the Microsoft Custom Translator API(https://custom-api.cognitive.microsofttranslator.com/swagger/)
to get list of the projects and so on. However I am receiving the 401 response (Unauthorized).
I am using the header authorization token as specified in similar Translator v3. API (https://learn.microsoft.com/en-us/azure/cognitive-services/translator/reference/v3-0-reference#authentication), however response is still 401.
The problem is not in the subscription, as the token authorization works well for the Translation v3. API.
Example of the call:
curl -X GET --header "Authorization: Bearer XYZ" https://custom-api.cognitive.microsofttranslator.com/api/texttranslator/v1.0/projects
Do you have any hints for the resolving the issue? Thank you.
I found this sample code on GitHub. https://github.com/MicrosoftTranslator/CustomTranslatorApiSamples
This sample code shows "resouceUri" is not "https://graph.microsoft.com". Please set "api://6981666b-e0e0-47d6-a039-35318677bf79/access_as_user" when you request authonize and token.
And execute ex. "https://custom-api.cognitive.microsofttranslator.com/api/texttranslator/v1.0/workspaces" and Set to header "Authorization Bearer (access token)".
If you try on swagger, you have to write "Bearer (access token)".
The Custom Translator API and the Translator V3 API are separate APIs. The Custom Translator API works with AAD v2 authentication since the operations on the Custom Translator are driven by the user as opposed to a subscription.
Please see below how to obtain an id_token for AAD v2.
https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-oauth-get-jwt-token
The mechanism of using this token with Custom Translator API remains the same as you have mentioned above
--header "Authorization: Bearer XYZ"
Already looked at How to use box-api to get the Shared item? and Box Developers documentation https://developers.box.com/docs/#shared-items. I have tried doing a request to https://api.box.com/2.0/shared_items in .NET code, in Firefox Poster and using curl. They all resulted in 404. I have verified that my file's shared link is open to anyone with a link. Here's my curl code (sanitized):
curl https://api.box.com/2.0/shared_items -H "Authorization: Bo
xAuth api_key=xxxxxxxxxxxxxxxxxxxxx" -H "BoxApi: shared_link=https://
app.box.com/s/yyyyyyyyyyyyyyyyyyyyyyyyyyyy"
{"type":"error","status":404,"code":"not_found","help_url":"http:\/\/developers.
box.com\/docs\/#errors","message":"Not Found","request_id":"196207167555469c3017
14b"}
What might be the problem? I tried a wrong api_key and got back 401 so I know the whole setup is correct.
Your API key shouldn't be included anywhere in the request. I believe that form of authorization was used in the old v1 API and is now deprecated. There's a cURL example in the docs you linked to that shows what your authorization header should look like:
curl https://api.box.com/2.0/shared_items
-H "Authorization: Bearer ACCESS_CODE"
-H "BoxApi: shared_link=SHARED_LINK"
For more info on how to obtain the access token that goes into the authorization header, take a look at the OAuth tutorial.
The reason why authentication is required is because the API will return info about the item within the context of the caller's permissions. For example, if the creator of the shared link makes the API call, then private information (such as the item's full path within their account) will be returned. If another user makes the call, then that private information will be omitted.
That being said, you're still able to anonymously download an open shared link by navigating to it directly. You only need to use the API if you want more information about the item that the link points to.
I have some audio recordings on Google Drive
the files are "viewable by anyone with the link"
I have created a podcast feed that links to these files
In order for a podcast client to download the files, it needs a direct download link. The Google Drive API returns two fields in a file's metadata that can play this role:
webContentLink is intended to be used in a browser. It allows my podcast client to download files less than 25MB; unfortunately, over this amount Google requires user confirmation since the file is not virus-scanned. This user-confirmation step prevents my podcast clients from downloading the file if it is over 25MB.
downloadUrl is what you're supposed to use, but I cannot get it to work at all. If I copy-paste a downloadUrl directly into my browser's address bar, I get nothing. Similarly my podcast client can't download anything with a downloadUrl.
This issue seems unresolved and suggests this is still broken, but I have a few questions:
should I need to submit an API key with the downloadUrl request? No key is needed for webContentLink.
is there a workaround for this issue?
When requesting the file with the downloadUrl you must specify the following authorization in your request header:
"Authorization: Bearer $token"
Where $token is the access_token returned by gapi for the user like this:
gapi.auth2.getAuthInstance().currentUser.get().getAuthResponse().access_token;
So if you were using curl the request would be something like this:
curl -o download -H "Authorization: Bearer $token" $downloadUrl
Google will be retiring Latitude soon, along with Latitude's API. But they say on their blog that Location History will still be stored and users will be able to access their history on Google Maps' Location History Dashboard. Do you know if there will be any API for receiving that location history, as there was for Google Latitude?
I've discovered that I can dynamically load my location history for any date using the following url:
https://maps.google.com/locationhistory/b/0/kml?startTime=1373666400000&endTime=1373752800000
by changing timestamps in "startTime" and "endTime" parameters. Unfortunately it's in .kml and no granularity data is included. Come on, Google - Latitude has some devoted users who relay on it on daily basis, don't kill it :(
In case you want the data as JSON with accuracy and not just the locations, you can just make the same request that the website makes. Looking at the inspector shows that it makes a request to https://maps.google.com/locationhistory/b/0/apps/pvjson?t=0. You can replay the same request with cURL (or any other way to make a POST request).
curl 'https://maps.google.com/locationhistory/b/0/apps/pvjson?t=0' -H 'origin: https://maps.google.com' -H 'accept-encoding: gzip,deflate,sdch' -H 'x-manualheader: [SOME STRING]' -H 'accept-language: en-GB,en;q=0.8,en-US;q=0.6,de;q=0.4,pt;q=0.2' -H 'cookie: GDSESS=[COOKIE DATA]' -H 'x-client-data: [ANOTHER STRING]' -H 'user-agent: [UA STRING]' -H 'content-type: application/x-www-form-urlencoded;charset=UTF-8' -H 'accept: */*' -H 'cache-control: max-age=0' -H 'referer: https://maps.google.com/locationhistory/b/0' -H 'dnt: 1' --data '[null,[BEGIN],[END],true]' --compressed
I left out my private cookie data and some details (in [..]) but you can google chrome ask to generate this for you in the developer console (right click on request -> copy as cURL). Just adapt the begin adn end times and download your location history as JSON. However, you need to download ranges of a couple of days and not everything at once. I'll leave this as an exercise for the reader.
I too am searching for an alternative solution to get my location back from Google.
Here are some facts:
Latitude will be replaced with location sharing on Google+
Android devices will continue to report location data to Google
Latitude will be removed (API, friends, website ...)
If devices will still be sending location data, Google should give us an API to fetch that data.
I've been looking into it and my location is shown on my G+ profile, but no info about granularity or timestamp.
It just says "Current location: [geocoded city]".
Reverse geocoding that address isn't very accurate. If I click on the address, Google Maps is opened in a new tab with coordinates, which seem to be pretty accurate.
So, if my location is on G+, I should be able to get it via the G+ API, right?
Well..
The only thing I've been able to find was this:
https://developers.google.com/+/api/latest/people
"currentLocation": string,
As you can see, the location data is returned as a string. I haven't tried it yet, but I would bet money that it would return the same as on my profile, just the name of the city, but not more accurate than that.
Right now it sucks. I want to get my location info, if the device is already sending it.
Installing a 3rd party app on my phone to feed my location on another service is redundant. And let's not forget about the additional battery drain and mobile data usage.
The logical step would be to put all of the latitude functionality to Google+.
We'll see, I doubt it.
Right now it just seems that they will be feeding on our privacy without us having any control or insight into it. :(
You can also download the data from Google Takeout. I know that this isn't an API, per se, but even a manual import is probably better than nothing.
https://google.com/takeout/
We would like to utilize box to store documents for our corporate collaboration app.
As such, our application has 2 roles for each space: admins and members
The idea is to:
create a folder for each space under a generic account in box owned by the application
create a corresponding set of box groups (ourapp-spacename-admins and ourapp-spacename-members)
assign the -admins group as co-owners of folder
assign the -members group as viewer/uploaders
From that point on, the only op needed is to manage changes to the groups.
It seems all of this is doable via the API except for assigning the proper roles to the groups. From what I can
tell, the API only allows individuals to added to collab roles. Is this the case? is there a workaround?
As of late last week, Box has APIs to let you collaborate a group onto a folder
You do it the same way you collaborate a user onto a folder
curl https://api.box.com/2.0/collaborations \
-H "Authorization: Bearer ACCESS_TOKEN" \
-d '{"item": { "id": "FOLDER_ID", "type": "folder"}, "accessible_by": { "id": "GROUP_ID"}, "role": "editor"}' \
-X POST
There currently isn't a capability for interacting with Groups in the V2 API, unfortunately; however, we're planning on adding it sometime in the coming months.