Glider
Loading...
Searching...
No Matches
GenTokenEC2.py
Go to the documentation of this file.
1#!/usr/bin/env python
2
3from apiclient.discovery import build
4from httplib2 import Http
5from oauth2client import file, client, tools
6from apiclient.http import MediaFileUpload
7from oauth2client.tools import argparser, run_flow
8import os
9
10args = argparser.parse_args()
11args.noauth_local_webserver = True
12
13
14full_path = __file__
15rel_path = full_path.split("/")[:-1]
16rel_path = "/".join(rel_path)
17
18
19CLIENT_SECRET = rel_path+"/client_secret.json"
20
21
22SCOPES = ["https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth/drive.readonly",
23"https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.metadata",
24"https://www.googleapis.com/auth/drive.photos.readonly"]
25
26
27store = file.Storage(rel_path+"/token.json")
28
29creds = store.get()
30if not creds or creds.invalid:
31 flow = client.flow_from_clientsecrets(CLIENT_SECRET, SCOPES)
32 creds = run_flow(flow, store, args)
33
34drive_service = build("drive", "v3", http=creds.authorize(Http()))