【问题标题】:google oauth2 api connection refused谷歌 oauth2 api 连接被拒绝
【发布时间】:2015-08-09 08:03:50
【问题描述】:

我正在使用 Google API 库在我们一直在构建的 Web 应用程序中进行服务器到服务器的通信。它适用于我们的开发和测试服务器,但是,当我们将应用程序移至生产环境时,尝试获取 Oauth2 令牌时,Curl 命令会导致连接被拒绝。

在我们的开发和测试服务器上:

curl -v https://accounts.google.com/o/oauth2/token

成功,并返回完整的 405 响应

在我们的生产服务器上,curl 命令导致

curl -v https://accounts.google.com/o/oauth2/token         
* About to connect() to accounts.google.com port 443 (#0)
*   Trying 216.58.216.205... Connection refused
*   Trying 2607:f8b0:4009:808::200d... Failed to connect to 2607:f8b0:4009:808::200d: Network is unreachable
* Success
* couldn't connect to host
* Closing connection #0
curl: (7) Failed to connect to 2607:f8b0:4009:808::200d: Network is unreachable

谷歌是否将我们的网站列入黑名单?所有这些服务器都在同一个域中。

【问题讨论】:

    标签: google-api google-oauth


    【解决方案1】:

    事实证明,实际上是我们的 DMZ 防火墙阻止了传出请求

    【讨论】:

      【解决方案2】:

      这解决了我的问题。

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HEADER, 0);
          curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
          curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
      

      问候, 卡尔佩什

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-02-26
        • 1970-01-01
        • 2019-09-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-08-08
        • 2017-10-12
        相关资源
        最近更新 更多