cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: Malformed authorize_url returned from DropboxOAuth2FlowNoRedirect.start()

Malformed authorize_url returned from DropboxOAuth2FlowNoRedirect.start() Python API

aplowman
Explorer | Level 4
Go to solution

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

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

I see, thanks for the information! 

View solution in original post

3 Replies 3

Greg-DB
Dropbox Staff
Go to solution

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
Explorer | Level 4
Go to solution

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
Dropbox Staff
Go to solution

I see, thanks for the information! 

Need more support?