A Cloudflare Worker that provides direct links to files on Google Drive. 📂
This worker can search through all your drives (including shared drives), and returns the search results in plaintext or in JSON format. 📚🔍
-
Create a new Google Cloud Platform project.
- Visit the Google Cloud Console.
- Click the project drop-down and select New Project.
- Enter a project name and click Create.
-
Enable the Google Drive API for the project.
- In the Cloud Console, go to the Dashboard and click Enable APIs and Services.
- Search for "Google Drive" and select the Google Drive API.
- Click Enable.
-
Create credentials for the Google Drive API.
- Go to the Credentials section.
- Click Create credentials, then select OAuth client ID.
- Set the application type to Other.
- Enter a name for the OAuth client ID, then click Create.
-
Obtain the client ID and client secret.
- After the OAuth client is created, you'll be able to see your client ID and client secret.
-
Fill the details in the script index.js.
- Provide your client ID, client secret and Google account's refresh token.
-
Create your Cloudflare Worker.
- Go to the Cloudflare Workers page and create a new worker.
- Replace the existing worker script with the index script.
- Take note of the worker's URL, which looks like
https://x.y.workers.dev
.
And that's it! 🎉 You're now ready to use your Cloudflare Worker with Google Drive.
After you create the Cloudflare Worker, take note of its URL which looks like https://x.y.workers.dev
. You can change this URL on the Cloudflare Workers page, but make sure it's non-guessable. 🔒
Here are the requests you can make to this URL:
GET request | Response |
---|---|
https://x.y.workers.dev/search/*SomeSearchQuery* |
Search results on an HTML page 📃 |
https://x.y.workers.dev/searchjson/*SomeSearchQuery* |
Search results in JSON format 📄 |
This project builds upon the work of: