0
我正嘗試使用Python(Flask)和DropBox API來構建應用程序。我試圖授權一個用戶,所以我跟進了python的教程。Dropbox身份驗證不能在Python上工作
from flask import Flask, render_template, url_for
from dropbox import client, rest, session
# Dropbox Settings
APP_KEY = 'gb83a6gpdo4kba6'
APP_SECRET = 'w5q0yhj9ikiw39g'
ACCESS_TYPE = 'app_folder'
# Flask Config
DEBUG = True
app = Flask(__name__)
app.config.from_object(__name__)
@app.route("/")
def home():
dropboxAccount = dropboxAccessToken = dropboxClient = None
# Dropbox Auth
dropboxSession = session.DropboxSession(app.config['APP_KEY'], app.config['APP_SECRET'], app.config['ACCESS_TYPE'])
requestToken = dropboxSession.obtain_request_token()
try:
dropboxAccessToken = dropboxSession.obtain_access_token(requestToken)
dropboxClient = dropboxClient.DropboxClient(dropboxSession)
dropboxAccount = dropboxClient.account_info()
except Exception, e:
print e
dropboxAuthUrl = dropboxSession.build_authorize_url(requestToken, oauth_callback = "http://localhost:5000/")
context = {
'dropboxAuthUrl' : dropboxAuthUrl,
'dropboxAccount' : dropboxAccount
}
return render_template('layout.html', context = context)
if __name__ == "__main__":
app.run()
但是,授權不起作用。從我的本地主機嘗試,用戶點擊該線所產生的鏈接:
dropboxSession.build_authorize_url(requestToken, oauth_callback = "http://localhost:5000/")
而且,到DropBox的授權頁面,顯示應用程序的信息和選項,允許或拒絕。當我點擊「允許」按鈕時,它會將我重定向回去,當我檢查我的帳戶應用程序時,新應用程序不在此處列出。回調網址如下所示:
http://localhost:5000/dropbox/?uid={some_uid}&oauth_token={some_token}
任何人都知道最新情況怎麼回事?
在此先感謝!