Google Drive API

Thanks to this guy, whose question and gist helps me understand the google api and requests for it to get access for google drive.


I found everything!

If anybody will be confused like me:
Get your google drive your_api_key from here:

Google API KEY

in section with name “API keys” – or you can generate it by pushing “New Credentials” -> “API key”

Also you can get your token with google “quick start” even for python3:

Your token will be saved on system user’s folder (C:/Users/user/.credentials) or (/root/.credentials) for Linux if you run it under “root”. The token is in “access_token” key value.

Then you can generate request, but at first check this:

And this is working example to get list of your google drive files:

import requests

url = ""
header = {'Authorization':"Bearer " + token}
list_files = requests.get(url+key, headers=header)
answer = list_files.json()


Token is expiring very soon!


Для русскоязычных ребят ключевое слово: google api key получить

Curl example from docs:


A call to the drive.files endpoint (the Drive API) using the access_token query string parameter might look like the following, though you’ll need to specify your own access token:


Here is a call to the same API for the authenticated user (me) using the Authorization: Bearer HTTP header:

GET /drive/v2/files HTTP/1.1
Authorization: Bearer 1/fFBGRNJru1FQd44AzqT3Zg

You can try out with the curl command-line application. Here’s an example using the HTTP header option (preferred):

curl -H "Authorization: Bearer 1/fFBGRNJru1FQd44AzqT3Zg"

Or, alternatively, the query string parameter option:


About trianglesis

Александр Брюндтзвельт - гений, филантроп, 100 гривен в кармане. Этот блог - "сток" моих мыслей и заметок. Достаточно одного взгляда на него, чтобы понять, что такой же бардак творится у меня в голове. Если вам этот бардак интересен - милости прошу.
Bookmark the permalink.