I am using python sdk to list and download files but getting stuck at authetication. Using this code to authenticate user to allow access.
from dropbox import DropboxOAuth2Flow, oauth
import http_status
APP_KEY = 'mykey'
APP_SECRET = 'mysecretkey'
def get_dropbox_auth_flow(web_app_session):
redirect_uri = "https://my-web-server.org/dropbox-auth-finish"
return DropboxOAuth2Flow(
APP_KEY, APP_SECRET, redirect_uri, web_app_session,
"dropbox-auth-csrf-token")
# URL handler for /dropbox-auth-start
def dropbox_auth_start(web_app_session, request):
authorize_url = get_dropbox_auth_flow(web_app_session).start()
redirect_to(authorize_url)
# URL handler for /dropbox-auth-finish
def dropbox_auth_finish(web_app_session, request):
try:
oauth_result = \
get_dropbox_auth_flow(web_app_session).finish(
request.query_params)
except oauth.BadRequestException as e:
http_status(400)
except oauth.BadStateException as e:
# Start the auth flow again.
redirect_to("/dropbox-auth-start")
except oauth.CsrfException as e:
http_status(403)
except oauth.NotApprovedException as e:
flash('Not approved? Why not?')
return redirect_to("/home")
except oauth.ProviderException as e:
logger.log("Auth error: %s" % (e,))
http_status(403)
Following: https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#module-dropbox.oauth
Getting "Unresolved reference 'redirect_to'" same with logger and flash. I also get 'http_status' is not callable. Do I need Flask to run this code? I am trying to build a simple python script that will let user authenticate using browser.