One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
aplowman
5 years agoExplorer | Level 4
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
I see, thanks for the information!
- Greg-DB
Dropbox 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
- aplowmanExplorer | 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):
1. Go to: https://www.dropbox.com/oauth2/authorize?response_type=code&client_id=REMOVED 2. Click "Allow" (you might have to log in first). 3. Copy the authorization code.
Enter the authorization code here:Anyway, this isn't a problem for me, now that I know the URL is properly formed outside of Jupyter Lab.
Thanks!
- Greg-DB
Dropbox Staff
I see, thanks for the information!
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,947 PostsLatest Activity: 4 hours ago
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!