我正在尝试设置一个第三方服务,它使用Uber API来拉取客户历史记录。我已经运行了一个本地的Flask应用程序,它执行auth_flow并重定向到优步登录页面。输入正确的凭据后,重定向似乎永远不会结束,因此在发布的图像中出现错误。
import os
from datetime import datetime
from flask import Flask, request, flash, url_for, redirect, \
render_template, abort, send_from_directory, redirect
from uber_rides.auth import AuthorizationCodeGrant
app = Flask(__name__)
app.config.from_pyfile('flaskapp.cfg')
# Configure Uber Oauth2.0
auth_flow = AuthorizationCodeGrant(
'<client_id>',
'history',
'<client_secret>',
'http://localhost:8080'
)
@app.route('/')
def index():
auth_url = auth_flow.get_authorization_url()
return redirect(auth_url, code=302)
if __name__ == '__main__':
app.run(debug=True)
这是我的代码。在Uber developer仪表板中,我添加了http://localhost:8080作为重定向URI,并选中了scopes下的history
选项。
我做错了什么?
发布于 2017-01-11 23:23:50
我没有看到任何回调的路径...看起来是这样的:用户打开应用程序,被重定向到auth_url (我假设那是优步身份验证页面),用户授权你的应用程序,用户被重定向到http://localhost:8080。此重定向命中索引路由,用户返回到auth_url。用户第二次看到优步身份验证页面时,他的会话仍然有效,并被重定向回http://localhost:8080。这会创建一个永无止境的循环。
一种解决方案是将重定向URL设置为命中不同的回调路由,例如http://localhost:8080/callback。
https://stackoverflow.com/questions/41593088
复制相似问题