Forum Discussion

aplowman's avatar
aplowman
Explorer | Level 4
5 years ago
Solved

Malformed authorize_url returned from DropboxOAuth2FlowNoRedirect.start() Python API

I am trying to use the `DropboxOAuth2FlowNoRedirect` example in the Python class docstring. It looks like this:

 

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:
    oauth_result = auth_flow.finish(auth_code)
except Exception as e:
    print('Error: %s' % (e,))
    return

dbx = Dropbox(oauth_result.access_token)

The resulting `authorize_url` seems to be malformed: it includes "&" instead of just "&", meaning when navigating to it, Dropbox returns an error: unknown field "amp". Is this a bug or am I doing something wrong?

 

Thanks

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    Thanks for the report. This issue doesn't seem to reproduce for me though. To help us investigate, can you share:

    • the version of the Dropbox Python library you have installed
    • the version of Python you're using
    • the full output you get
    • aplowman's avatar
      aplowman
      Explorer | Level 4

      Ah. It is something to do with Jupyter Lab. The URL is fine in the iPython REPL and in Jupyter notebook. I am using the Python dropbox package version 10.1.1 and Python 3.8.2.

       

      If I run this code:

       

      from dropbox import DropboxOAuth2FlowNoRedirect, Dropbox
      
      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 = input("Enter the authorization code here: ").strip()
      try:
          oauth_result = auth_flow.finish(auth_code)
      except Exception as e:
          print('Error: %s' % (e,))
      
      dbx = Dropbox(oauth_result.access_token)

      in a cell within Jupyter Lab, I get the following output (with client ID removed):

       

       

      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        I see, thanks for the information! 

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,947 PostsLatest Activity: 4 hours ago
351 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!