當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。