Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
abhannan
8 years agoHelpful | Level 5
Python DropboxOAuth2Flow Error: WSGIRequest' object does not support item assignment
I'm trying to build a webapp with Django and using dropbox SDK v2 for Python. I'm stuck at Authentication and getting error that
WSGIRequest' object does not support item assignment
Here is my code:
from dropbox import DropboxOAuth2Flow
from django.shortcuts import redirect
def get_dropbox_auth_flow(web_app_session):
redirect_uri = "https://www.my-dummy-server.com"
APP_KEY = 'my-app-key'
APP_SECRET = 'my-app-secret'
return DropboxOAuth2Flow(
APP_KEY, APP_SECRET, redirect_uri, web_app_session, "dropbox-auth-csrf-token")
def dropbox_auth_start(web_app_session):
authorize_url = get_dropbox_auth_flow(web_app_session).start()
return redirect(authorize_url)Can anyone please help?
3 Replies
- abhannan8 years agoHelpful | Level 5
I changed the code to the following but still I'm not able to resolve.
def dropbox_auth_start(request, web_app_session):
if request.method == 'GET':
authorize_url = get_dropbox_auth_flow(web_app_session).start()
return redirect(authorize_url)I'm learning dropbox API, isn't there any example / gist / tutorial that how OAuth authentication works in API. I'm not able to find anything on the internet.
- Greg-DB8 years ago
Dropbox Community Moderator
[Cross-linking for reference: https://stackoverflow.com/questions/48482899/dropbox-api-with-django-authentication ]
It looks like your question is more about using Django itself than the Dropbox API, so I'm afraid I can't offer much help. It looks like you already got some help on this on StackOverflow anyway though.
There's a basic outline of how you would use the OAuth app authorization flow in the Dropbox Python SDK with DropboxOAuth2Flow in the documentation here:
https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.oauth.DropboxOAuth2Flow
That's not written for any particular web framework in particular, so you'd need to hook up the session and request information for whichever framework you are using (e.g., Django, in your case).
- iamlordaubrey8 years agoExplorer | Level 3
In case someone needs this:
The first argument passed is usually the request object. Simply reference the session object on the request like so: web_app_session.session
Updated:
from dropbox import DropboxOAuth2Flow from django.shortcuts import redirect def get_dropbox_auth_flow(web_app_session): redirect_uri = "https://www.my-dummy-server.com" APP_KEY = 'my-app-key' APP_SECRET = 'my-app-secret' return DropboxOAuth2Flow( APP_KEY, APP_SECRET, redirect_uri, web_app_session, "dropbox-auth-csrf-token") def dropbox_auth_start(web_app_session): authorize_url = get_dropbox_auth_flow(web_app_session.session).start() return redirect(authorize_url)
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
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, Facebook or Instagram.
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!