Skip to content

nick8592/GoogleAPI-Download-File

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoogleAPI-Download-File

You can follow the Official Instruction provide by google.

You have to create a Google Cloud Project first, and open the Google Workspace API then activate "Google Drive API". Download the JSON file, then you can continue for the following work.

Installation

Clone the repo.

cd <workspace_folder>
git clone https://github.com/nick8592/GoogleAPI-Download-File.git

Create environments

cd GoogleAPI-Download-File
conda env create -f environment.yaml
conda activate api

Quickstart

Move credentials.json file to workspace folder.
Insure you've renamed your JSON filename to creadentials.json.

└── <workspace_folder>
    └──  GoogleAPI-Download-File
        ├── img_source
        ├── README.md
        ├── .gitignore
        ├── environment.yaml
        ├── credentials.json <------
        └── download_file.py

Find your file's file_id. Copy shared link.
Get shared file path Paste shared link on new window, the red line words is your file_id.
Red line is file_id

Replace <your_file_id> with your file_id in download_file.py.

file_id = '<your_file_id>'

Run download_file.py

python download_file.py

For the first time, you will see the below warning. Following the instruction as below images.
google_auth_1 google_auth_2 google_auth_3
After you press the final continue button. You should see the window shows below information. And if so, then you can close the window. The file should be downloaded at the same time.

The authentication flow has completed. You may close this window.

If download successfully, you can find the file in your GoogleAPI_Download_File folder, and the terminal should show

>>> File '<your_file_name>' downloaded successfully.

References

Google Drive API(Python)從 0 開始到從 URL 下載檔案範例
建立 Google Cloud 專案
啟用 Google Workspace API
Python 快速入門導覽課程
下載及匯出檔案
Set up Application Default Credentials

About

Download file on google drive via google provided API.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages