google app engine - Trying to connect to Dropbox using its Python API, but failing -
this in google app engine. i'm trying load dropbox api request authorization page @ beginning, redirect otherpage when "allow" button clicked, , use client other purposes. here's code far:
import webapp2 import cgi import urllib2 dropbox import client, rest, session # app key , secret dropbox developer website app_key = 'key' app_secret = 'secret' access_type = 'dropbox' sess = session.dropboxsession(app_key, app_secret, access_type) request_token = sess.obtain_request_token() class mainpage(webapp2.requesthandler): def get(self): url = sess.build_authorize_url(request_token, '') self.redirect(url) class otherpage(webapp2.requesthandler): def get(self): try: self.response.write('<html><body>testing:') access_token = sess.obtain_access_token(request_token) client = client.dropboxclient(sess) ...(other code)... self.response.write('</body></html>') except: self.response.write('<html><body>incorrect authorization code, please try again.</body></html')
none of code in try block after
access_token = sess.obtain_access_token(request_token)
is executed, , program goes except part. doesn't crash, writes "incorrect authorization code, please try again" other web page.
edit: server prints command line:
info 2013-08-13 03:43:50,755 sdk_update_checker.] checking updates sdk. info 2013-08-13 03:43:51,233 sdk_update_checker.] sdk date. info 2013-08-13 03:43:51,252 api_server.] starting api server at: info 2013-08-13 03:43:51,270 dispatcher.] starting module "default" running at: info 2013-08-13 03:43:51,273 admin_server.] starting admin server at: info 2013-08-13 03:43:57,594 module.] default: "get / http/1.1" 302 - info 2013-08-13 03:44:01,062 module.] default: "get /other?uid=162326169&oauth_token=qoxo0r0ki3q5nzwm http/1.1" 200 118 info 2013-08-13 03:44:01,224 module.] default: "get /favicon.ico http/1.1" 404 154
edit 2: solved. after removing try , exception blocks , running what's in try block, took issue line
client = client.dropboxclient(sess)
after renaming first client else, worked.
Comments
Post a Comment