本文整理汇总了Python中oauth2client.tools.argparser.parse_args方法的典型用法代码示例。如果您正苦于以下问题:Python argparser.parse_args方法的具体用法?Python argparser.parse_args怎么用?Python argparser.parse_args使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oauth2client.tools.argparser
的用法示例。
在下文中一共展示了argparser.parse_args方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from oauth2client.tools import argparser [as 别名]
# 或者: from oauth2client.tools.argparser import parse_args [as 别名]
def main():
# Arguments parsing
parser = argparse.ArgumentParser("Client ID and Secret are mandatory arguments")
parser.add_argument("-i", "--id", required=True, help="Client id", metavar='<client-id>')
parser.add_argument("-s", "--secret", required=True, help="Client secret",
metavar='<client-secret>')
parser.add_argument("-c", "--console", default=False,
help="Authenticate only using console (for headless systems)", action="store_true")
args = parser.parse_args()
# Scopes of authorization
activity = "https://www.googleapis.com/auth/fitness.activity.write"
body = "https://www.googleapis.com/auth/fitness.body.write"
location = "https://www.googleapis.com/auth/fitness.location.write"
scopes = activity + " " + body + " " + location
flow = OAuth2WebServerFlow(args.id, args.secret, scopes)
storage = Storage('google.json')
flags = ['--noauth_local_webserver'] if args.console else []
run_flow(flow, storage, argparser.parse_args(flags))
示例2: get_user_account_credentials
# 需要导入模块: from oauth2client.tools import argparser [as 别名]
# 或者: from oauth2client.tools.argparser import parse_args [as 别名]
def get_user_account_credentials(self):
from oauth2client.client import OAuth2WebServerFlow
from oauth2client.file import Storage
from oauth2client.tools import run_flow, argparser
flow = OAuth2WebServerFlow(
client_id=('495642085510-k0tmvj2m941jhre2nbqka17vqpjfddtd'
'.apps.googleusercontent.com'),
client_secret='kOc9wMptUtxkcIFbtZCcrEAc',
scope=self.scope,
redirect_uri='urn:ietf:wg:oauth:2.0:oob')
storage = Storage('bigquery_credentials.dat')
credentials = storage.get()
if credentials is None or credentials.invalid or self.reauth:
credentials = run_flow(flow, storage, argparser.parse_args([]))
return credentials
示例3: initYoutube
# 需要导入模块: from oauth2client.tools import argparser [as 别名]
# 或者: from oauth2client.tools.argparser import parse_args [as 别名]
def initYoutube():
flow = flow_from_clientsecrets(constants.YOUTUBE_CLIENT_SECRETS_FILE,\
message=constants.MISSING_CLIENT_SECRETS_MESSAGE,\
scope=constants.YOUTUBE_READ_WRITE_SCOPE,
redirect_uri='http://localhost:8080/')
storage = Storage("%s-oauth2.json" % sys.argv[0])
credentials = storage.get()
if credentials is None or credentials.invalid:
flags = argparser.parse_args()
credentials = run_flow(flow, storage, flags)
else:
print("Found valid oauth2 json")
youtube = build(constants.YOUTUBE_API_SERVICE_NAME, constants.YOUTUBE_API_VERSION,
http=credentials.authorize(httplib2.Http()))
print("Done authentication with Youtube")
return youtube
示例4: get_youtube_service
# 需要导入模块: from oauth2client.tools import argparser [as 别名]
# 或者: from oauth2client.tools.argparser import parse_args [as 别名]
def get_youtube_service():
flow = flow_from_clientsecrets(CLIENT_SECRETS_FILE,
scope=YOUTUBE_UPLOAD_SCOPE,
message=MISSING_CLIENT_SECRETS_MESSAGE)
storage = Storage("oauth2-youtube.json")
credentials = storage.get()
flags = argparser.parse_args(args=[])
if credentials is None or credentials.invalid:
credentials = run_flow(flow, storage, flags)
return build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION,
http=credentials.authorize(httplib2.Http()))
示例5: get_spreadsheet_service
# 需要导入模块: from oauth2client.tools import argparser [as 别名]
# 或者: from oauth2client.tools.argparser import parse_args [as 别名]
def get_spreadsheet_service():
flow = flow_from_clientsecrets(CLIENT_SECRETS_FILE, scope=SPREADSHEETS_SCOPE)
flow.user_agent = "FRC YouTube Uploader"
storage = Storage("oauth2-spreadsheet.json")
credentials = storage.get()
flags = argparser.parse_args(args=[])
if credentials is None or credentials.invalid:
credentials = run_flow(flow, storage, flags)
http = credentials.authorize(httplib2.Http())
discoveryUrl = ('https://sheets.googleapis.com/$discovery/rest?''version=v4')
return build('sheets', 'v4', http=http, discoveryServiceUrl=discoveryUrl)
示例6: main
# 需要导入模块: from oauth2client.tools import argparser [as 别名]
# 或者: from oauth2client.tools.argparser import parse_args [as 别名]
def main():
client_id = sys.argv[1]
client_secret = sys.argv[2]
scope = sys.argv[3]
flow = OAuth2WebServerFlow(client_id, client_secret, scope)
storage = Storage('google.json')
flags = argparser.parse_args([])
run_flow(flow, storage, flags)