为什么 Google 驱动 API / Oauth2 刷新令牌请求,returns 错误提示 "SSL is required to perform this operation."?

Why does Google Drive API / Oauth2 refresh token request, returns an error saying "SSL is required to perform this operation."?

我是 OAuth2 的新手,这让我感到困惑,为什么我的刷新令牌请求得到了 "SSL is required to perform this operation." 的响应,而显然我们从 DigitalOcean 获得了免费的 SSL。

  public function refresh_token($test = false){

    $url = "www.googleapis.com/oauth2/v4/token";
    $credentials = $this->credentials();
    $refresh_token = $credentials->refresh_token;
    $client_id = $credentials->client_id;
    $client_secret = $credentials->client_secret;
    $redirect =  base_url($credentials->redirect_url);

    $data = "client_id=$client_id&client_secret=$client_secret&refresh_token=$refresh_token&grant_type=refresh_token";

    $access = $this->curl_post($url,$data,array('Content-Type: application/x-www-form-urlencoded'));

    if($test){
      echo "<pre>";
      echo $access;
      die();
    }

    $access = json_decode($access);

    if(isset($access->access_token)){
      $this->admin->update(
        array('access_token'=>$access->access_token),
        'sheet_config',
        array('status'=>1)
      );
      echo $access->access_token;
      return true;
    }else{
      echo $access->error->message;
      return false;
    }
  }

我期待一个新令牌的结果或一些错误,比如你的证书被搞砸了,或者你需要先用数字海洋配置一些关于你的 SSL 的东西

我对 SSL 之类的东西一窍不通,但我很确定我们有 SSL 因为我们 运行 https://

因为在 HTTP 上调用授权服务器真的很糟糕!

这个$url = "www.googleapis.com/oauth2/v4/token";和做$url = "http://www.googleapis.com/oauth2/v4/token"是一样的;并且没有授权服务器会对此做出响应。

话虽如此,我认为您只是缺少 url.

正面的 https
$url = "https://www.googleapis.com/oauth2/v4/token";