def get_tokens():
tokens = None
try:
# if we already have tokens, load and use them
tokens = load_data_from_file(DATA_FILE)['tokens']
except:
pass
if not tokens:
# if we need to get tokens, start the Native App authentication process
tokens = do_native_app_authentication(CLIENT_ID, REDIRECT_URI, SCOPES)
try:
save_data_to_file(DATA_FILE, 'tokens', tokens)
except:
pass
return tokens
评论列表
文章目录