Use python dropbox API with django -
i'm using dropboxoauth2flow method described dropbox api v1.6 in django v1.5.3 application , i'm having 400 error when redirected dropbox oauth2 authorization page.
when go to dropbox_auth_start url redirected to:
and 400 error occurs.
the "dropbox-auth-csrf-token" written in session file way.
my django code:
views.py
def get_dropbox_auth_flow(web_app_session): redirect_uri = "http://www.mydomain.com" return dropboxoauth2flow('blahblahblah', 'blehblehbleh', redirect_uri, web_app_session, "dropbox-auth-csrf-token") # url handler /dropbox-auth-start def dropbox_auth_start(request): authorize_url = get_dropbox_auth_flow(request.session).start() return httpresponseredirect(authorize_url) # url handler /dropbox-auth-finish def dropbox_auth_finish(request): try: access_token, user_id, url_state = get_dropbox_auth_flow(request.session).finish(request.get) except dropboxoauth2flow.badrequestexception, e: http_status(400) except dropboxoauth2flow.badstateexception, e: # start auth flow again. return httpresponseredirect("http://www.mydomain.com/dropbox_auth_start") except dropboxoauth2flow.csrfexception, e: return httpresponseforbidden() except dropboxoauth2flow.notapprovedexception, e: raise e except dropboxoauth2flow.providerexception, e: raise e
urls.py
from django.conf.urls import patterns, url, include django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^dropbox_auth_start/?$',views.dropbox_auth_start), url(r'^dropbox_auth_finish/?$',views.dropbox_auth_finish), )
just @smarx said, switched http , https, , worked fine.
Comments
Post a Comment