I am looking to write a server application to upload files to Google Drive. I was previously using the Documents List API, but I see that is deprecated. I\'d like to move to the
Since the gdrive tool is no longer maintained. I found an official and better way.
Using curl.
sudo apt install curl
Create credentials > Configure OAth consent screen (if needed) > Application type > TV and limited input devices > Save your client id and a client secret.
curl -d "client_id=
Expected response:
{"device_code": "",
"user_code": "xxx-xxx-xxx",
"expires_in": 1800,
"interval": 5,
"verification_url": "https://www.google.com/device"}
Then go to the https://www.google.com/device
--> Enter "user_code"
--> Give relevant permissions.
"device_code"
and "user_code"
values.curl -d client_id=
Expected Output:
{
"access_token": ".....",
"expires_in": 3599,
"refresh_token": "....",
"scope": "https://www.googleapis.com/auth/drive.file",
"token_type": "Bearer"
}
Save the "access_token"
value.
Start uploading
curl -X POST -L -H "Authorization: Bearer
CAUTION
Make zip archives of your files before uploading. The above code works for archived files. I uploaded 10gb archive with the above method successfully.
Source