AI-generated Key Takeaways
-
Utilize the Google Drive Labels advanced service in Apps Script to create and manage labels for your Google Drive files and folders, leveraging the Drive Labels API.
-
To use this advanced service, ensure you enable the Advanced Drive Service in your Apps Script project settings before implementation.
-
Access comprehensive documentation and support resources for the Google Drive Labels API, which uses the same structure as the public API, in the provided references.
-
Explore the provided sample code snippets to learn how to list available labels, retrieve specific labels by name, and list labels applied to Drive items using Apps Script.
Create and manage labels for your Drive files and folders with the Google Drive Labels advanced service. With this advanced service, you can use all the features of the Drive Labels API in Apps Script.
To apply or remove Drive labels, use the Advanced Drive Service.
Reference
For more information about this service, see the documentation for the Google Drive Labels API. Like all advanced services in Apps Script, the Drive Labels API service uses the same objects, methods, and parameters as the public API.
To report issues and find other support, see the Google Drive Labels API support guide.
Sample code
The sample code below uses version 2 of the API.
List labels
The following code sample shows how to get a list of labels available to the user making the request.
Get a label
The following code sample shows how to get a single label by its resource name (which is the string value of the label). To find the label name, get the list of labels through the API or use the Drive labels manager. For more information on the labels manager, go to Manage Drive labels.
List labels for a Drive item
The following code sample shows how to get a Drive item and list all labels applied to that item.