forgejae.blogg.se

Google drive api how to get file id
Google drive api how to get file id








google drive api how to get file id

Now, save the file and go to your terminal. Your access token will be stored in credentials/credentials.json upon the browser authentication, which I will go through after this. from apiclient import discovery from httplib2 import Http from oauth2client import client, file, tools # define path variables credentials_file_path = './credentials/credentials.json' clientsecret_file_path = './credentials/client_secret.json' # define API scope SCOPE = '' # define store store = file.Storage(credentials_file_path) credentials = store.get() # get access token if not credentials or credentials.invalid: flow = client.flow_from_clientsecrets(clientsecret_file_path, SCOPE) credentials = n_flow(flow, store) Let’s write the code that needs to go into connect_to_google_drive.py. first_medium_project | |_credentials | | | |_client_secret.json | |_connect_to_google_drive.py The connect_to_google_drive.py is the Python file that contains instructions to connect to Google Drive API. Your project structure should look like this to begin with. If you don’t know how to do this, follow this tutorial here. MacBook-Pro:~ bobthedude$ virtualenv venv_google_api MacBook-Pro:~ bobthedude$ source venv_google_api/bin/activate # install all the dependent packages (venv_google_api) MacBook-Pro:~ bobthedude$ pip install google-api-python-client oauth2clientĬreate a folder in the project directory called credentials to store your client_secret.json which you can download from your Google Console. We are going to start with installing google-api-python-client and oauth2client libraries. Before we begin, let’s set up a virtual environment to contain and install all the dependencies for this project.










Google drive api how to get file id