1

我目前已经在 uber 上设置了一个开发者帐户,并且在我的 PC 和http://localhost:7000/submit上本地运行一切正常

我可以登录并使用 API。这对于测试端点非常有用。但是,我的最终目标是在我的移动应用程序上使用端点。所以我转到重定向 URL 并将其切换到https://my_new_url:7000/submit

我正在为我的服务器使用 Flask,并以下列方式使用 SSL:

if __name__ == '__main__':
    application.run(host='0.0.0.0',port=7000,ssl_context='adhoc') 

但是,当导航到我的基本 url 时,我收到以下错误:

错误

基本重定向 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,还是我配置错误?

4

1 回答 1

0

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

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

于 2016-02-25T21:11:14.783 回答