cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Python DropboxOAuth2Flow Error: WSGIRequest' object does not support item assignment

Explorer | Level 4

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 3
Highlighted

Re: Python DropboxOAuth2Flow Error: WSGIRequest' object does not support item assignment

Explorer | Level 4

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.

Highlighted

Re: Python DropboxOAuth2Flow Error: WSGIRequest' object does not support item assignment

Dropboxer
Dropboxer

[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).

Highlighted

Re: Python DropboxOAuth2Flow Error: WSGIRequest' object does not support item assignment

Explorer | 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)

 

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?