Google 使用 Django Shell 幻灯片 API
Google Slides API with Django Shell
根据 https://developers.google.com/slides/quickstart/python 中的示例,我尝试了:
$ python manage.py shell --settings=myapp.settings-test
In [1]: from apiclient.discovery import build
...: from httplib2 import Http
...: from oauth2client import file, client, tools
...: SCOPES = 'https://www.googleapis.com/auth/presentations.readonly'
...: flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
...: store = file.Storage('credentials.json')
...: creds = tools.run_flow(flow, store)
...:
usage: manage.py [--auth_host_name AUTH_HOST_NAME] [--noauth_local_webserver]
[--auth_host_port [AUTH_HOST_PORT [AUTH_HOST_PORT ...]]]
[--logging_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
manage.py: error: unrecognized arguments: shell --settings=myapp.settings-dev
An exception has occurred, use %tb to see the full traceback.
是否有不同的方法从 django shell 中设置 Google 幻灯片?或者我可以做些什么来让它发挥作用?
我看到有人有类似的问题,但我无法从中汲取灵感。
设置,然后像下面那样使用 flags
就成功了
flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
flags = tools.argparser.parse_args(args=[])
creds = tools.run_flow(flow, store, flags)
H/t 到答案
根据 https://developers.google.com/slides/quickstart/python 中的示例,我尝试了:
$ python manage.py shell --settings=myapp.settings-test
In [1]: from apiclient.discovery import build
...: from httplib2 import Http
...: from oauth2client import file, client, tools
...: SCOPES = 'https://www.googleapis.com/auth/presentations.readonly'
...: flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
...: store = file.Storage('credentials.json')
...: creds = tools.run_flow(flow, store)
...:
usage: manage.py [--auth_host_name AUTH_HOST_NAME] [--noauth_local_webserver]
[--auth_host_port [AUTH_HOST_PORT [AUTH_HOST_PORT ...]]]
[--logging_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
manage.py: error: unrecognized arguments: shell --settings=myapp.settings-dev
An exception has occurred, use %tb to see the full traceback.
是否有不同的方法从 django shell 中设置 Google 幻灯片?或者我可以做些什么来让它发挥作用?
我看到有人有类似的问题
设置,然后像下面那样使用 flags
就成功了
flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
flags = tools.argparser.parse_args(args=[])
creds = tools.run_flow(flow, store, flags)
H/t 到答案