cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Musicians, convert your MuseScore files to PDF to play music on the go! Learn more 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: Python DropboxOAuth2Flow Error: WSGIRequest' object does not support item assignment

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

abhannan
Helpful | Level 5

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

abhannan
Helpful | 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-DB
Dropbox Staff

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

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

 

Need more support?