我正在使用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)
我出于显而易见的原因排除了应用密钥和应用密钥。
答案 0 :(得分:0)
问题似乎在这一行:
access_token, user_id
DropboxOAuth2FlowNoRedirect.finish
方法返回一个OAuth2FlowNoRedirectResult
对象。您尝试解压缩到元组(=LOWER(
CONCATENATE(
DEC2HEX(RANDBETWEEN(0,POWER(16,8)),8), "-",
DEC2HEX(RANDBETWEEN(0,POWER(16,4)),4),"-","4",
DEC2HEX(RANDBETWEEN(0,POWER(16,3)),3),"-",
DEC2HEX(RANDBETWEEN(8,11)),
DEC2HEX(RANDBETWEEN(0,POWER(16,3)),3),"-",
DEC2HEX(RANDBETWEEN(0,POWER(16,8)),8),
DEC2HEX(RANDBETWEEN(0,POWER(16,4)),4)
)
)
),有效地尝试迭代它来执行此操作,这会失败,因为没有其他任何东西可以迭代。
有一些示例代码显示如何在DropboxOAuth2FlowNoRedirect.finish
的文档中使用DropboxOAuth2FlowNoRedirect
。
答案 1 :(得分:0)
修改以下代码行,如下所示 -
access_token,user_id= flow.finish(code)
到
access_token= flow.finish(code)
flow.finish
方法不返回元组。它返回一个对象。