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


Python dropbox.DropboxOAuth2FlowNoRedirect方法代码示例

本文整理汇总了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) 
开发者ID:donpiekarz,项目名称:spellbook,代码行数:26,代码来源:application.py

示例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 
开发者ID:maxking,项目名称:paper-to-git,代码行数:21,代码来源:dropbox.py


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