-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
40 lines (34 loc) · 1.15 KB
/
Copy pathmain.py
File metadata and controls
40 lines (34 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from apiclient import discovery
from httplib2 import Http
from oauth2client import client, file, tools
import json
SCOPES = "https://www.googleapis.com/auth/forms.responses.readonly"
DISCOVERY_DOC = "https://forms.googleapis.com/$discovery/rest?version=v1"
store = file.Storage("token.json")
creds = None
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets("credentials.json", SCOPES)
creds = tools.run_flow(flow, store)
service = discovery.build(
"forms",
"v1",
http=creds.authorize(Http()),
discoveryServiceUrl=DISCOVERY_DOC,
static_discovery=False,
)
# Prints the responses of your specified form:
form_id = "<FORM_UID>"
# get meta data of form (make sure the scopes are defined above)
# result = service.forms().get(formId=form_id).execute()
# get all responses of form
result = service.forms().responses().list(formId=form_id).execute()
# get a single response of form (make sure the scopes are defined above)
# response_id = "<_RESPONSE_ID>"
# result = (
# service.forms()
# .responses()
# .get(formId=form_id, responseId=response_id)
# .execute()
# )
with open('data.json', 'w') as f:
json.dump(result, f)