本文整理汇总了Python中dropbox.DropboxOAuth2FlowNoRedirect方法的典型用法代码示例。如果您正苦于以下问题:Python dropbox.DropboxOAuth2FlowNoRedirect方法的具体用法?Python dropbox.DropboxOAuth2FlowNoRedirect怎么用?Python dropbox.DropboxOAuth2FlowNoRedirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dropbox
的用法示例。
在下文中一共展示了dropbox.DropboxOAuth2FlowNoRedirect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: command_dropbox_connect
# 需要导入模块: import dropbox [as 别名]
# 或者: from dropbox import DropboxOAuth2FlowNoRedirect [as 别名]
def command_dropbox_connect(args):
import dropbox
if args.spellbook_name is not None:
print('ERR: sync is only for all books')
return
app_key = 'ow3gosk8pb9bhkr'
app_secret = 'w3eqoqx5scb64pd'
flow = dropbox.DropboxOAuth2FlowNoRedirect(app_key, app_secret)
# Have the user sign in and authorize this token
authorize_url = flow.start()
print('1. Go to: ' + authorize_url)
print('2. Click "Allow" (you might have to log in first)')
print('3. Copy the authorization code.')
code = collect_str("the authorization code here")
# This will fail if the user enters an invalid authorization code
access_token, user_id = flow.finish(code)
client = dropbox.Dropbox(access_token)
print('successfully linked account: ', client.users_get_current_account().name.display_name)
with open(DROPBOX_TOKEN_PATH, 'w') as fout:
fout.write(access_token)
示例2: get_new_auth_token
# 需要导入模块: import dropbox [as 别名]
# 或者: from dropbox import DropboxOAuth2FlowNoRedirect [as 别名]
def get_new_auth_token(self):
# Run the dropbox OAuth Flow to get the user's OAuth Token.
auth_flow = DropboxOAuth2FlowNoRedirect(config.dropbox.app_key,
config.dropbox.app_secret)
authorize_url = auth_flow.start()
print("1. Go to: " + authorize_url)
print("2. Click \"Allow\" (you might have to log in first).")
print("3. Copy the authorization code.")
auth_code = input("Enter the authorization code here: ").strip()
try:
oauth_result = auth_flow.finish(auth_code)
except Exception as e:
print('Error: %s' % (e,))
return
config.write_to_user_config('dropbox', 'api_token',
oauth_result.access_token)
return oauth_result.access_token