【问题标题】:Uber Base Redirect Error优步基地重定向错误
【发布时间】: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 与您在开发者中心注册并指定的一致。

标签: https flask uber-api


【解决方案1】:

正如您从 /v1/oauth2/authorize 端点收到的错误响应中所述,问题在于您发送的 URI 的基础必须与在 Uber Developers Dashboard 中注册您的应用程序期间使用的重定向 URI 匹配。

另请参阅此答案:https://stackoverflow.com/a/35638160/313113

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-04-14
    • 2021-03-12
    • 2014-06-20
    • 1970-01-01
    • 2018-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多