Uber API - 尝试获取访问令牌返回 html 响应



我能够完成身份验证过程的前两个步骤。在步骤 3 中,当我尝试通过交换授权代码来获取访问令牌时,我收到一个 html 响应,其中显示"请求不再有效"。

<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Uber </title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  <link rel="icon" href="https://d1a3f4spazzrp4.cloudfront.net/login/images/favicon.a767a268b86a6ce7d1099bec4a9e37aa.ico" type="image/x-icon" />
  <link rel="stylesheet" href="https://d1a3f4spazzrp4.cloudfront.net/login/style-login/style.ca8265c07903e433432af8462ac98f4e.css">
  <link href="https://d1a3f4spazzrp4.cloudfront.net/uber-icons/3.8.1/uber-icons.css" rel="stylesheet"/>
    <link rel="stylesheet" href="https://d1a3f4spazzrp4.cloudfront.net/uber-fonts/2.0.1/superfine.css"/>
  </head>
<body>
    <div class="content">
        <div class="icon-item text--center">
            <a href="https://www.uber.com/">
                <i class="icon icon_uber
                        push--top push-small--bottom
">
                </i>
            </a>
        </div>
  <p class="login-error-title text--center">Error</p>
  <p class="login-error text--center push--top">
      Your request is no longer valid
  </p>
    </div>
<script src="https://d1a3f4spazzrp4.cloudfront.net/login/scripts/analytics.30328e3569a665795cf94cbbf63985a8.js"></script>
<script type="text/javascript">
    Analytics.init({
        services: {
            tealium: {
                account: 'uber',
                profile: 'main',
                env: 'prod',
                geo: ''
            }
        }
    });
</script>
</body>
</html>

我能够在 JSON 响应中更早地获取访问令牌。然后我做了一个小的代码重构。重构后,我没有得到 JSON 响应。

我尝试断开应用程序与我的优步个人资料的连接并重试。但仍然是同样的错误。

你在用 Node 吗?下面是一个使用 Node+Express 的工作示例。还包括一个香草 JS Web 应用程序,只需在授权后提供access_token即可进行进一步请求。

最新更新