3

我在通過社交網站進行Google oauth登錄時遇到問題。我正在將當前在本地和在生產中使用的應用遷移到GAE。在Laravel和Socialite上使用Google App Engine

我正在使用Laravel 5.1的shpasser gae軟件包,該軟件運行正常。 第一次登錄請求會顯示Google權限屏幕,但應該在回調中出現curl錯誤。

cURL error 7: (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) 
in CurlFactory.php line 168 
at CurlFactory::createRejection(object(EasyHandle), array('errno' => '7', 'error' => '', 'url' => 'https://accounts.google.com/o/oauth2/token', 'content_type' => null, 'http_code' => '0', 'header_size' => '0', 'request_size' => '0', 'filetime' => '-1', 'ssl_verify_result' => '0', 'redirect_count' => '0', 'total_time' => '0', 'namelookup_time' => '0.080153', 'connect_time' => '0', 'pretransfer_time' => '0', 'size_upload' => '0', 'size_download' => '0', 'speed_download' => '0', 'speed_upload' => '0', 'download_content_length' => '-1', 'upload_content_length' => '-1', 'starttransfer_time' => '0', 'redirect_time' => '0', 'redirect_url' => '', 'primary_ip' => '', 'certinfo' => array(), 'primary_port' => '0', 'local_ip' => '', 'local_port' => '0')) in CurlFactory.php line 132 

我試圖在Laravel使用這個

final public function setSslVerification($certificateAuthority = true, $verifyPeer = true, $verifyHost = 2) 
    { 
     $opts = $this->config[self::CURL_OPTIONS] ?: array(); 

     if ($certificateAuthority === true) { 
      // use bundled CA bundle, set secure defaults 
      $opts[CURLOPT_CAINFO] = __DIR__ . '/etc/ca-certificates.crt'; 
      $opts[CURLOPT_SSL_VERIFYPEER] = true; 
      $opts[CURLOPT_SSL_VERIFYHOST] = 2; 
     } elseif ($certificateAuthority === false) { 
      unset($opts[CURLOPT_CAINFO]); 
      $opts[CURLOPT_SSL_VERIFYPEER] = false; 
      $opts[CURLOPT_SSL_VERIFYHOST] = 0; 
     } elseif ($verifyPeer !== true && $verifyPeer !== false && $verifyPeer !== 1 && $verifyPeer !== 0) { 
      throw new InvalidArgumentException('verifyPeer must be 1, 0 or boolean'); 
     } elseif ($verifyHost !== 0 && $verifyHost !== 1 && $verifyHost !== 2) { 
      throw new InvalidArgumentException('verifyHost must be 0, 1 or 2'); 
     } else { 
      $opts[CURLOPT_SSL_VERIFYPEER] = $verifyPeer; 
      $opts[CURLOPT_SSL_VERIFYHOST] = $verifyHost; 
      if (is_file($certificateAuthority)) { 
       unset($opts[CURLOPT_CAPATH]); 
       $opts[CURLOPT_CAINFO] = $certificateAuthority; 
      } elseif (is_dir($certificateAuthority)) { 
       unset($opts[CURLOPT_CAINFO]); 
       $opts[CURLOPT_CAPATH] = $certificateAuthority; 
      } else { 
       throw new RuntimeException(
        'Invalid option passed to ' . self::SSL_CERT_AUTHORITY . ': ' . $certificateAuthority 
       ); 
      } 
     } 

     $this->config->set(self::CURL_OPTIONS, $opts); 

     return $this; 
    } 

但仍然有同樣的錯誤狂飲包更改證書的位置。我也有這個在我的php.ini文件

; enable function that are disabled by default in the App Engine PHP runtime 
google_app_engine.enable_functions = "php_sapi_name, php_uname, getmypid" 
google_app_engine.allow_include_gs_buckets = "my-bucket-name" 
allow_url_include = 1 
extension = "curl.so" 
google_app_engine.enable_curl_lite = 「1」 

從說不定重做不社會名流的登錄名和只使用狂飲,看到如果我仍然得到錯誤暗戰選項,除了。

UPDATE 在文檔中,它指出您不能同時捲曲和捲曲。這已被更改,因此只有extension = "curl.so"位於php.ini文件中。它不解決問題,而是需要改變

+0

我越看這個,我相信Google App Engine可能會阻止我的回覆 –

回答

2

經過大量的谷歌搜索和研究,我已成功地從這一問題https://stackoverflow.com/questions/31631596/curl-error-7-during-guzzle-request-on-google-app-engine?noredirect=1#comment51981622_31631596

在Laravel社會名流使用狂飲解決此問題,也感謝用戶歐米茄該軟件包在安裝在Google App Engine上時無法找到證書文件。最近提交加入了線

// Google app engine 
+  '/etc/ca-certificates.crt', 

default_ca_bundle功能

加入這一行,如果你還沒有更新到最新狂飲。該目錄是

供應商/ guzzlehttp /狂飲/ src目錄/ functions.php中

確保你沒有擴展curl.so在php.ini文件中啓用做。