尝试逐步遵循Dropbox Core Python文档,但由于意外错误而暂停。
elif args.sync:
print("syncing")
import dropbox
flow = dropbox.client.DropboxOAuth2FlowNoRedirect(dropbox_appKey, dropbox_appSecret)
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
access_token, user_id = flow.finish(code)
client = dropbox.client.DropboxClient(access_token)
print("linked account: ", client.account_info())
回溯:
Traceback (most recent call last):
File "./eldiario", line 92, in <module>
access_token, user_id = flow.finish(code)
File "/usr/local/lib/python3.4/site-packages/dropbox/client.py", line 1233, in finish
return self._finish(code, None)
File "/usr/local/lib/python3.4/site-packages/dropbox/client.py", line 1101, in _finish
response = self.rest_client.POST(url, params=params)
File "/usr/local/lib/python3.4/site-packages/dropbox/rest.py", line 316, in POST
return cls.IMPL.POST(*n, **kw)
File "/usr/local/lib/python3.4/site-packages/dropbox/rest.py", line 254, in POST
post_params=params, headers=headers, raw_response=raw_response)
File "/usr/local/lib/python3.4/site-packages/dropbox/rest.py", line 227, in request
raise ErrorResponse(r, r.read())
dropbox.rest.ErrorResponse: [400] 'invalid_grant'
任何想法都有什么问题吗?
答案 0 :(得分:0)
您似乎在strip
之后遗漏了一些括号。
它应该是这样的:
code = input("Enter the authorization code here: ").strip()