[英]Using Google App Engine with Laravel and Socialite
我通過社交網站登錄Google oauth時遇到問題。 我正在將當前在本地和生產中運行的應用程序遷移到GAE。
我正在使用lapasser gae包用於Laravel 5.1並且運行正常。 第一個登錄請求顯示谷歌權限屏幕,但在回調中我收到卷曲錯誤。
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使用的Guzzle包中的證書位置
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”
耗盡選項,除了可能沒有社交網站重做登錄,只使用Guzzle,看看我是否仍然得到錯誤。
更新在文檔中,它聲明您不能同時激活curl lite和full curl。 這已被更改,因此php.ini文件中只有extension = "curl.so"
。 它不能解決問題,但需要改變
經過大量谷歌搜索和研究后,我設法解決了這個問題,也感謝用戶Omega從這個問題https://stackoverflow.com/questions/31631596/curl-error-7-during-guzzle-request-on-google -app引擎?noredirect = 1#comment51981622_31631596
在Laravel中,Socialite使用Guzzle包,此軟件包在Google App Engine上安裝時無法找到證書文件。 最近的一次提交增加了這條線
// Google app engine
+ '/etc/ca-certificates.crt',
在里面
default_ca_bundle函數
如果您尚未更新到最新的Guzzle,請添加此行。 目錄是
供應商/ guzzlehttp /狂飲/ SRC / functions.php的
確保您的php.ini文件中沒有啟用擴展curl.so。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.