1

On my Raspberry Pi running raspbian jessie I tried to go through the OAuth2 flow to connect a program to my dropbox using the dropbox SDK for Python which I installed via pip.

For a test, I copied the code from the documentation (and defined the app-key and secret, of course):

from dropbox import DropboxOAuth2FlowNoRedirect

auth_flow = DropboxOAuth2FlowNoRedirect(APP_KEY, 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 = raw_input("Enter the authorization code here: ").strip()

try:
    access_token, user_id = auth_flow.finish(auth_code)
except Exception, e:
    print('Error: %s' % (e,))
    return

dbx = Dropbox(access_token)

I was able to get the URL and to click allow. When I then entered the authorization code however, it printed the following error:

Error: 'str' object has no attribute 'copy'

Using format_exc from the traceback-module, I got the following information:

Traceback (most recent call last):
  File "test.py", line 18, in <module>
    access_token, user_id = auth_flow.finish(auth_code)
  File "/usr/local/lib/python2.7/dist-packages/dropbox/oauth.py", line 180, in finish
    return self._finish(code, None)
  File "/usr/local/lib/python2.7/dist-packages/dropbox/oauth.py", line 50, in _finish
    url = self.build_url(Dropbox.HOST_API, '/oauth2/token')
  File "/usr/local/lib/python2.7/dist-packages/dropbox/oauth.py", line 111, in build_url
    return "https://%s%s" % (self._host, self.build_path(target, params))
  File "/usr/local/lib/python2.7/dist-packages/dropbox/oauth.py", line 89, in build_path
    params = params.copy()
AttributeError: 'str' object has no attribute 'copy'

It seems the build_path method expects a dict 'params' and receives a string instead. Any ideas?

10
  • 1
    What version of the library are you using? See github.com/dropbox/dropbox-sdk-python/issues/31... this should be fixed in 3.42. Commented Nov 21, 2015 at 19:56
  • Thank you! I have 3.41. So I will wait until 3.42 is available. Commented Nov 21, 2015 at 20:36
  • What do you mean "wait until 3.42 is available?" That's the current version on PyPI. Commented Nov 21, 2015 at 20:54
  • I git-cloned it after your comment and it was 3.41? I'll give it a try again tomorrow. Commented Nov 21, 2015 at 23:42
  • Huh. PyPI definitely has 3.42, but it does look like maybe that's not on GitHub. I'll look into it. Commented Nov 22, 2015 at 11:33

1 Answer 1

1

Thanks to smarx for his comment. The error is a known issue and will be fixed in version 3.42 of the SDK. source

Sign up to request clarification or add additional context in comments.

1 Comment

Correction: was fixed in 3.42. :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.