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
评论列表
文章目录