当前位置: 首页>>代码示例>>Python>>正文


Python argparser.parse_args方法代码示例

本文整理汇总了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)) 
开发者ID:praveendath92,项目名称:fitbit-googlefit,代码行数:22,代码来源:auth_google.py

示例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 
开发者ID:SignalMedia,项目名称:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda,代码行数:21,代码来源:gbq.py

示例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 
开发者ID:shashanksurya,项目名称:YoCoolSpotify,代码行数:20,代码来源:views.py

示例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())) 
开发者ID:NikhilNarayana,项目名称:FRC-YouTube-Uploader,代码行数:17,代码来源:youtubeAuthenticate.py

示例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) 
开发者ID:NikhilNarayana,项目名称:FRC-YouTube-Uploader,代码行数:17,代码来源:youtubeAuthenticate.py

示例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) 
开发者ID:keptenkurk,项目名称:BS440,代码行数:10,代码来源:auth_google.py


注:本文中的oauth2client.tools.argparser.parse_args方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。