Python 3.x 什么是TypeError:';OAuth2FlowNoRedirectResult';对象不是不可分的平均数

Python 3.x 什么是TypeError:';OAuth2FlowNoRedirectResult';对象不是不可分的平均数,python-3.x,dropbox-api,Python 3.x,Dropbox Api,我正在使用dropbox python扩展,收到以下错误消息: TypeError: 'OAuth2FlowNoRedirectResult' object is not iterable 这是迄今为止的代码: import dropbox flow = dropbox.DropboxOAuth2FlowNoRedirect(app_key, app_secret) # Have the user sign in and authorize this token authorize_url

我正在使用dropbox python扩展,收到以下错误消息:

TypeError: 'OAuth2FlowNoRedirectResult' object is not iterable
这是迄今为止的代码:

import dropbox
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 = input("Enter the authorization code here: ").strip()

# This will fail if the user enters an invalid authorization code
access_token, user_id = flow.finish(code)

f = open('Top Secret.jpg', 'rb')
response = client.put_file('Top Secret.jpg', f)
print ("uploaded:", response)
f.close()

f, metadata = client.get_file_and_metadata('/Top Secret.jpg')
out = open('Test.jpg', 'wb')
out.write(f.read())
out.close()
print (metadata)

出于明显的原因,我排除了应用程序密钥和应用程序机密。

问题似乎在这一行:

access_token, user_id = flow.finish(code)
那里的方法返回单个对象。您试图解包到一个元组(
access\u-token,user\u-id
),实际上是试图对其进行迭代,但由于没有任何其他可迭代的内容,因此失败了


在的文档中有一些示例代码显示了如何使用。

修改以下代码行,如下所示-

access_token,user_id= flow.finish(code)

流式抛光

方法不返回元组。它返回单个对象

access_token= flow.finish(code)