This document contains Google Drive API-specific authorization and authentication information. Before reading this document, be sure to read the Google Workspace's general authentication and authorization information at Learn about authentication and authorization.
Configure OAuth 2.0 for authorization
Configure the OAuth consent screen and choose scopes to define what information is displayed to users and app reviewers, and register your app so that you can publish it later.
Drive API scopes
To define the level of access granted to your app, you need to identify and declare authorization scopes. An authorization scope is an OAuth 2.0 URI string that contains the Google Workspace app name, what kind of data it accesses, and the level of access. Scopes are your app's requests to work with Google Workspace data, including users' Google Account data.
When your app is installed, a user is asked to validate the scopes used by the app. Generally, you should choose the most narrowly focused scope possible and avoid requesting scopes that your app doesn't require. Users more readily grant access to limited, clearly described scopes.
When possible, we recommend using non-sensitive scopes as it grants per-file access scope and narrows access to specific features needed by an app.
The Drive API supports the following scopes:
Scope code | Description | Usage |
---|---|---|
https://www.googleapis.com/auth/drive.appdata |
View and manage the app's own configuration data in your Google Drive. | Recommended Non-sensitive |
https://www.googleapis.com/auth/drive.install |
Allow apps to appear as an option in the "Open with" or the "New" menu. | Recommended Non-sensitive |
https://www.googleapis.com/auth/drive.file |
Create new Drive files, or modify existing files, that you open with an app or that the user shares with an app while using the Google Picker API or the app's file picker. | Recommended Non-sensitive |
https://www.googleapis.com/auth/drive.apps.readonly |
View apps authorized to access your Drive. | Sensitive |
https://www.googleapis.com/auth/drive |
View and manage all your Drive files. | Restricted |
https://www.googleapis.com/auth/drive.readonly |
View and download all your Drive files. | Restricted |
https://www.googleapis.com/auth/drive.activity |
View and add to the activity record of files in your Drive. | Restricted |
https://www.googleapis.com/auth/drive.activity.readonly |
View the activity record of files in your Drive. | Restricted |
https://www.googleapis.com/auth/drive.meet.readonly |
View Drive files created or edited by Google Meet. | Restricted |
https://www.googleapis.com/auth/drive.metadata |
View and manage metadata of files in your Drive. | Restricted |
https://www.googleapis.com/auth/drive.metadata.readonly |
View metadata for files in your Drive. | Restricted |
https://www.googleapis.com/auth/drive.scripts |
Modify your Google Apps Script scripts' behavior. | Restricted |
The Usage column in the table above indicates the sensitivity of each scope, according to the following definitions:
Recommended / Non-sensitive: These scopes provide the smallest scope of authorization access and only requires basic app verification. For information on this requirement, see Verification requirements.
Recommended / Sensitive: These scopes provide access to specific Google User Data that's authorized by the user for your app. It requires you to go through additional app verification. For information on this requirement, see Sensitive and Restricted Scope Requirements.
Restricted: These scopes provide wide access to Google User Data and require you to go through a restricted scope verification process. For information on this requirement, see Google API Services User Data Policy and Additional Requirements for Specific API Scopes. If you store restricted scope data on servers (or transmit), then you must go through a security assessment.
If your app requires access to any other Google APIs, you can add those scopes as well. For more information about Google API scopes, see Using OAuth 2.0 to Access Google APIs.
For more information about specific OAuth 2.0 scopes, see OAuth 2.0 Scopes for Google APIs.
OAuth verification
Using certain OAuth scopes might require that your app proceed through OAuth App Verification Help Center. Read the OAuth app FAQs to determine when your app should go through verification and what type of verification is required. See also the Google Drive Terms of Service.
When to use a restricted scope
For Drive, only the following application types may access restricted scopes:
- Platform-specific and web apps that provide local sync or automatic backup of users' Drive files.
- Productivity and educational applications whose user interface might involve interaction with Drive files (or their metadata or permissions). Productivity applications include task management, note taking, workgroup communications, and classroom collaboration applications.
- Reporting and security applications that provide user or customer insight into how files are shared or accessed.
To continue using restricted scopes, you should prepare your app for restricted scope verification.
Migrate an existing app from restricted scopes
If you've developed a Drive app using any of the restricted scopes, we recommend migrating your app to use a non-sensitive scope as it grants per-file access scope and narrows access to specific features needed by an app. Many apps work with per-file access without any changes. If you're using your own file picker, we recommend switching to the Google Picker API which fully supports different scopes.
Benefits of the drive.file
OAuth scope
Using the drive.file
OAuth scope and the Google Picker API optimizes both user
experience and safety for your app.
The drive.file
OAuth scope lets users choose which files they want to share
with your app. This gives them more control and confidence that your app's
access to their files is limited and more secure. In contrast, requiring broad
access to all Drive files could discourage users from interacting
with your app. The following are some reasons why you should use drive.file
scope:
Usability: The
drive.file
scope works with all Drive API REST Resources which means you can use it the same way you use broader OAuth scopes.Features: The Google Picker API provides a similar interface to the Drive UI. This includes several views showing previews and thumbnails of Drive files, and an inline, modal window so users never leave the main app.
Convenience: Apps can apply filters for certain Drive file types (such as Google Docs, Sheets, and photos) when using a filter on Google Picker files.
Also, since drive.file
is non-sensitive, it allows for a more streamlined
verification process.
Save refresh tokens
Save refresh tokens in secure, long-term storage and continue to use them as long as they remain valid.