Reputation: 23
I'm trying to get the resourcekey of file from google drive api
In the description of google api On 13th September they gonna update for file permission they said 'you must update your code for accessing files to include the appropriate resource keys' 'The resource key of an item is returned on the resourceKey field of the file metadata in the Drive API response'
but when I trying to get the file I can not find the resourcekey from the fields of the file metadata and also When i trying to do on the google api test, the response also doesn't have the resource key this follow is the result of api test
{
"kind": "drive#file",
"id": "1iLXfgFeTJi5Fhv",
"etag": "\"MTYyODc0MTU1ODg4Nw\"",
"selfLink": "https://www.googleapis.com/drive/v2/files/1iLXfgFeTJi5Fhv",
"alternateLink": "https://docs.google.com/spreadsheets/d/1iLXfgFeTJi5Fhv/edit?usp=drivesdk",
"embedLink": "https://docs.google.com/spreadsheets/d/1iLXfgFeTJi5Fhv",
"iconLink": "https://drive-thirdparty.googleusercontent.com/16/type/application/vnd.google-apps.spreadsheet",
"thumbnailLink": "https://docs.google.com/feeds/vt?gd=true&id=1iLXfgFeTJi5Fhv&v=3&s=AMedNnoAAAAAYRtUMTI6h451YaMRq96KNGUB_WwYBPDv&sz=s220",
"title": "CSS_v1_212232173224",
"mimeType": "application/vnd.google-apps.spreadsheet",
"labels": {
"starred": false,
"hidden": false,
"trashed": false,
"restricted": false,
"viewed": true
},
"copyRequiresWriterPermission": false,
"createdDate": "2021-08-12T04:10:07.115Z",
"modifiedDate": "2021-08-12T04:12:38.887Z",
"lastViewedByMeDate": "2021-08-17T04:16:16.628Z",
"markedViewedByMeDate": "1970-01-01T00:00:00.000Z",
"sharedWithMeDate": "2021-08-17T04:16:16.628Z",
"version": "10",
"parents": [],
"exportLinks": {
"application/x-vnd.oasis.opendocument.spreadsheet": "https://docs.google.com/spreadsheets/export?id=1iLXfgFeTJi5Fhv",
"text/tab-separated-values": "https://docs.google.com/spreadsheets/export?id=1iLXfgFeTJi5Fhv&exportFormat=tsv",
"application/pdf": "https://docs.google.com/spreadsheets/export?id=1iLXfgFeTJi5Fhv&exportFormat=pdf",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "https://docs.google.com/spreadsheets/export?id=1iLXfgFeTJi5Fhv4&exportFormat=xlsx",
"text/csv": "https://docs.google.com/spreadsheets/export?id=1iLXfgFeTJi5Fhv&exportFormat=csv",
"application/zip": "https://docs.google.com/spreadsheets/export?id=1iLXfgFeTJi5Fhv&exportFormat=zip",
"application/vnd.oasis.opendocument.spreadsheet": "https://docs.google.com/spreadsheets/export?id=1iLXfgFeTJi5Fhv&exportFormat=ods"
},
"userPermission": {
"kind": "drive#permission",
"etag": "\"kKO0QvvB0TR5MI4KTDoDeWQE7AU\"",
"id": "me",
"selfLink": "https://www.googleapis.com/drive/v2/files/1iLXfgFeTJi5Fhv/permissions/me",
"role": "reader",
"type": "user"
},
"fileSize": "13706",
"quotaBytesUsed": "13706",
"ownerNames": [
""
],
"owners": [
{
"kind": "drive#user",
"displayName": "",
"isAuthenticatedUser": false,
"permissionId": "",
"emailAddress": ""
}
],
"lastModifyingUserName": "",
"lastModifyingUser": {
"kind": "drive#user",
"displayName": "",
"isAuthenticatedUser": false,
"permissionId": "",
"emailAddress": ""
},
"capabilities": {
"canCopy": true,
"canEdit": false
},
"editable": false,
"copyable": true,
"writersCanShare": true,
"shared": true,
"explicitlyTrashed": false,
"appDataContents": false,
"spaces": [
"drive"
]
}
how can i get the resourcekey for the file??
Upvotes: 1
Views: 1536
Reputation: 314
Phase 3: Drive enforces update—Beginning September 13, 2021 The update should finish by the end of September 2021.
Wait for the change affect ( maybe up to 24 hours )
Open google drive ( Search Box )
Result :
https://www.googleapis.com/drive/v3/files/${file_id}?fields=*
https://developers.google.com/drive/api/v3/reference/files
- shortcutDetails.targetResourceKey string The ResourceKey for the target file.
- resourceKey string A key needed to access the item via a shared link.
So a link that used to look like https://drive.google.com/file/d/${file_id}/
will now look like https://drive.google.com/file/d/${file_id}/view?resourcekey=xxxx-xxxx-xxxx-xxx
Upvotes: 1
Reputation: 11
You need to make sure that the resourceKey security update is already activated in your domain by going to Google Admin. You can find more detailed answer here https://issuetracker.google.com/issues/196862507
Upvotes: 1