【发布时间】:2016-01-25 01:53:36
【问题描述】:
我目前在 uber 上设置了一个开发者帐户,一切都在我的 PC 和http://localhost:7000/submit本地运行良好
我可以登录并使用 API。这对于测试端点非常有用。但是,我的最终目标是在我的移动应用程序上使用端点。于是我去了重定向网址,把它切换到https://my_new_url:7000/submit
我将 Flask 用于我的服务器,并以下列方式使用 SSL:
if __name__ == '__main__':
application.run(host='0.0.0.0',port=7000,ssl_context='adhoc')
但是,当导航到我的基本网址时,我收到以下错误:
错误
基本重定向 URI 与请求的重定向不匹配
基本 url 的代码如下所示:
def get_redirect_uri(request):
"""Return OAuth redirect URI."""
parsed_url = urlparse(request.url)
if parsed_url.hostname == 'localhost':
return 'http://{hostname}:{port}/submit'.format(
hostname=parsed_url.hostname, port=parsed_url.port
)
return 'https://{hostname}/submit'.format(hostname=parsed_url.hostname)
@application.route('/', methods=['GET'])
def signup():
params = {
'response_type': 'code',
'redirect_uri': get_redirect_uri(request),
'scopes': ','.join(config.get('scopes')),
}
url = generate_oauth_service().get_authorize_url(**params)
return redirect(url)
我必须先将应用程序列入白名单,然后才能更改重定向 URL,还是我配置错误?
【问题讨论】:
-
确保您的基本 url 与您在开发者中心注册并指定的一致。