As an admin on our Google domain I want to be able to drop a folder shortcut into our student's Google home folder (their 'My Drive').
How can I get the ID of their home folder (their 'My Drive') - every folder must have an ID, right?
(To clarify, I need to get a unique ID for each folder so I can access it programatically - the folder is also known as 'root' but this doesn't help. Every Google folder has a unique ID and I can't believe these folders are any different).
I can't see anything in the Drive or Directory APIs.
Google support says
'We use the popular programming Q&A website Stack Overflow to field
technical questions'
so I'm hoping someone from Google will help!
Thanks!
How can I get the ID of their home folder (their 'My Drive') - every folder must have an ID, right?
Every user on Google drive has a root folder. The id of that folder is "root" you can just place your shortcut there.
If you really want the "Real" file id for the root folder then
Do a file.get and pass it root as the file id
curl \
'https://www.googleapis.com/drive/v3/files/root?key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
response
{
"kind": "drive#file",
"id": "0AJpJkOVaKccEUk9PVA",
"name": "My Drive",
"mimeType": "application/vnd.google-apps.folder"
}
Related
I have some problem with shared drive in google drive API by using g-suite.
So, I set up on g-suite console options which one restrict sharing by link for shared drive users. That means when you create shared drive it's default parameter for option driveMembersOnly is true.
But when you sent API request for create shared drive with body - ("restrictions": {"driveMembersOnly": false }) - disk creating with opportunity shared files via links, so everything work, i tested it in august 2019.
But now - it's just don't work. I think something is changed and i need fix my code, but I use "try it" section on https://developers.google.com/drive/api/v3/reference/drives/create page, try to pass any parameter in "restrictions" section - and API just ignore this params.
So, I don't know. Maybe it's a bug? Or maybe google change console options behavior and it's overwriting this parameter for all my API requests.
Maybe some one faced with such problem?
Support of gsuite don't help with API problems.
And this is the request:
curl -X POST "https://www.googleapis.com/drive/v3/drives?requestId=123" -H "accept: application/json" -H "Authorization: bearer TOKEN" -H "content-type: application/json" -d "{ \"restrictions\": { \"driveMembersOnly\": false }, \"name\": \"shared drive name\"}"
I'd like to let website users load userProfile.html when they request www.website.com/userProfile (without .html).
There is nothing about that in docs.
You can serve HTML content without a .html suffix. It's important to set the content-type though. For example, with gsutil:
gsutil -h "Content-Type:text/html" cp /path/users/userProfile \
gs://www.website.com/userProfile
I want to download google drive folders file via wget how it is possible?
I have folder version in google drive and in that version folder all version apk file of my mobile app.
Folder tree like this
Version : -> mobileapp1.apk
-> mobileapp2.apk
-> mobileapp3.apk
And I want to download by passing version name. Is it possible with google drive and wget? I have already make folder Public on the web - Anyone on the Internet
You can download old version files using wget. In order to download old version files, Access token, File ID and Revision ID are required as the materials. The methods for retrieving the materials are follows. wget is used for all methods.
1. Access token
Reference : https://developers.google.com/identity/protocols/OAuth2
This is my old answer related to retrieving access token from Google OAuth2. Refresh Google drive access__token If this is useful for you, I'm glad.
2. File ID
In order to retrieve file ID, it searches it from file name using drive.files.list.
wget -q --header='Authorization: Bearer ### Access token ###' \
'https://www.googleapis.com/drive/v3/files?q=name="### FileName ###"&fields=files(id,name)' \
-O out.txt
By this, you can find FileID for the FileName in the out.txt. If there are several files with same name, please select one of them.
Reference : https://developers.google.com/drive/v3/reference/files/list
3. Revision ID
In order to retrieve revision ID, it retrieves revision list for the FileID using drive.revisions.list.
wget -q --header='Authorization: Bearer ### Access token ###' \
'https://www.googleapis.com/drive/v3/files/### FileID ###/revisions?fields=revisions(id%2CmodifiedTime)' \
-O out.txt
By this, you can find RevisionID for the FileID in the out.txt. Please select revision ID you want.
Reference : https://developers.google.com/drive/v3/reference/revisions/list
4. File for Revision ID
Retrieves File for Revision ID using drive.revisions.get.
wget -q --header='Authorization: Bearer ### Access token ###' \
"https://www.googleapis.com/drive/v3/files/### FileID ###/revisions/### RevisionID ###?alt=media" \
-O outputfilename
By this, a file with name of outputfilename can be retrieved.
Reference : https://developers.google.com/drive/v3/reference/revisions/get
Is the Google Drive's Root Folder Id permanent?
Will the Root Folder Id remain the same as long as the account exists?
As stated in the Work with Folders section of the api doc :
You can use the alias root to refer to the root folder anywhere a file ID is provided
That way you'll have the correct id for any user.
Recently an article on the box dev blog talked about an update in the V2 API functionality. http://developers.blog.box.com/2012/07/13/more-v2-updates/.
I am specifically talking about the share link for file/folders. The article says the API can be used to create/delete share links and also change the permission.But i do not see any such API on the http://developers.box.com/docs page.
Does anybody have any idea about this discrepancy? Is this available now in V2 or not?
Smart links are treated as an attribute of a folder or file and can be created by updating the metadata about the folder or file. This is done through the PUT method. You can see this here for files and here for folders.
For example, if you wanted to enable a shared link for a file you would make this call using cURL:
curl https://api.box.com/2.0/files/FILE_ID \
-H "Authorization: BoxAuth api_key=API_KEY&auth_token=AUTH_TOKEN" \
-d {"shared_link": {"access": "open"}} \
-X PUT