One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
george-silva
8 years agoNew member | Level 2
OAuth2 problems with Django and Django Db Backup
Hello all!
I'm having a problem regarding the usage of the DropBox API.
I'm using dropbox to backup a few of my databases, which it worked perfectly.
I'm using Django, Django dbbackup and internally it uses the dropbox api. I've checked and we are using the latest versions of all libraries.
I have generated a proper Oauth2 key, using your UI to do so. I've configured it properly on my side, and tried to generate a backup. the backup get's generated but the upload to dropbox fails with an 413 error.
dropbox.rest.ErrorResponse: [413] Error parsing response body or headers: Body - '<!DOCTYPE html>\n<html>\n<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">\ Headers - HTTPHeaderDict({'Content-Length': '25546', 'X-Robots-Tag': 'noindex, nofollow, noimageindex', 'Server': 'nginx', 'Connection': 'close', 'ETag': '"58c83253-63ca"', 'X-Dropbox-Request-Id': '9aa2ced5c801b7f47ca37e7c5704d6bd', 'Date': 'Thu, 30 Mar 2017 15:06:45 GMT', 'Content-Type': 'text/html'})
Can you help me?
Also another funny thing is that the generated key does not get persisted within my account. I ask to generate a new key, it does and it outputs it to me. I hit f5 to reload the page and it's gone, and I have the option to generate the key again.
Thoughts?
- Greg-DB
Dropbox Staff
Regarding the 413 error, can you share the HTTP request being sent? (Just be sure to redact the access token.) A 413 error should indicate that the request payload was too large, so we should first determine what you're sending.
Also, when you refer to your OAuth 2 "key", do you mean your OAuth 2 access token? The access token itself doesn't expire, so the app should store and re-use it. Exactly how the app does that is up to the app though, and since "Django dbbackup" is made by a third party, we can't offer support for Django dbbackup itself.
- george-silvaNew member | Level 2
Hey Greg,
The error is not that the payload is too large. Here's the title:
Error parsing response body or header
Analyzing your code for your python dropbox implementation, this error occurs if there is no error message returned in the payload. It's the last case of a large if condition, here: https://github.com/dropbox/dropbox-sdk-python/blob/master/dropbox/rest.py#L406-L408
How can I generate a new key for an Dropbox App?
Well, I've created a new app.
There are a bunch of sections, such as:
* Status
* Development Users
* app folder name
* etc
* OAuth2
In that section, (oauth2), there are the following options:
* redirect urls
* allow implicit grant
* generate key
This application, particularly does not comunicate with a lot of users, just one, me. So I've generated the key and used to communicate between my Django application and Dropbox. Each time I click it, it generates a new key. If I hit f5, it will not show that key again. If I hit generate key again, it will give me another key.
Since this worked before, I know this problem is not located in django-dbbackup.
I must be doing something wrong, because this looks like a generic "cant connect error".
What is the correct way to generate a key, for **my user** to be used with oauth2?
- Greg-DB
Dropbox Staff
Thanks for the additional information. Can you share the request itself though? That should help show what the issue is.
And yes, if you just need an access token for your own account on your own app, you can use that 'Generate' button to get one. The page will show it to you, and you should then copy it from the page, and then store and re-use it in your app. That page won't show it again if you refresh the page.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,950 PostsLatest Activity: 16 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!