Stay organized with collections Save and categorize content based on your preferences.
Create a JavaScript web application that makes requests to the Google Drive API.
Quickstarts explain how to set up and run an app that calls a Google Workspace API. This quickstart uses a simplified authentication approach that is appropriate for a testing environment. For a production environment, we recommend learning about authentication and authorization before choosing the access credentials that are appropriate for your app.
This quickstart uses Google Workspace's recommended API client libraries to handle some details of the authentication and authorization flow.
ObjectivesTo complete this quickstart, set up your environment.
Enable the APIBefore using Google APIs, you need to turn them on in a Google Cloud project. You can turn on one or more APIs in a single Google Cloud project.
In the Google Cloud console, enable the Google Drive API.
If you're using a new Google Cloud project to complete this quickstart, configure the OAuth consent screen. If you've already completed this step for your Cloud project, skip to the next section.
To authenticate end users and access user data in your app, you need to create one or more OAuth 2.0 Client IDs. A client ID is used to identify a single app to Google's OAuth servers. If your app runs on multiple platforms, you must create a separate client ID for each platform.
The newly created credential appears under OAuth 2.0 Client IDs.
Note the Client ID. Client secrets aren't used for Web applications.
Make a note of these credentials because you need them later in this quickstart.
Create an API keyindex.html
.In the index.html
file, paste the following sample code:
Replace the following:
YOUR_CLIENT_ID
: the client ID that you created when you authorized credentials for a web application.YOUR_API_KEY
: the API key that you created as a Prerequisite.In your working directory, install the http-server package:
In your working directory, start a web server:
http://localhost:8000
.Your JavaScript application runs and calls the Google Drive API.
Next stepsgoogle-api-javascript-client
section of GitHubExcept as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-08 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-08 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4