Using Google App Engine with Laravel and Socialite

374 views
Skip to first unread message

Chris Townsend

unread,
Aug 14, 2015, 8:21:43 AM8/14/15
to Google App Engine

! am having problems with Google oauth login via socialite. I am migrating the app which currently works locally and in production to GAE.

I am using the shpasser gae package for Laravel 5.1 and that is functioning correctly. The first login request displays the google permission screen like it should but on the callback I am getting a curl error.


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

I have tried changing the certificate location in the Guzzle package which Laravel uses to this


 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;
    }

But still having the same error. I also have this in my php.ini file

; 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

Running out of options, apart from maybe redoing the login without Socialite and just using Guzzle, and seeing if I still get the error.


UPDATE In the docs it states that you cannot have curl lite and full curl active at the same time. This has been changed, so that only extension = "curl.so" is in the php.ini file. It doesn't resolve the problem, but needed to change

Nick (Cloud Platform Support)

unread,
Aug 14, 2015, 11:16:20 AM8/14/15
to Google App Engine
Hi Chris,

You seem to have created a question which would be very on-topic at stackoverflow. Unfortunately this forum is not the place for it, however, since it's meant for more general / high-level discussion of the platform / services. If you post to stackoverflow, you'll have access to a much larger pool of developers and you'll also have the benefit of posting to a forum designed for specific-issue support. 

As the curl error docs suggest, error 7 is from not being able to connect, and this is likely because full curl is not enabled on the platform, only curl lite. 

Feel free to post your stackoverflow link back to this thread once you create your question as I'd be happy to look over it in that context, to help out.

Best wishes,

Nick

Chris Townsend

unread,
Aug 14, 2015, 11:41:00 AM8/14/15
to Google App Engine
Hi Nick, Thank you for your response.


Here is the link to my Stackoverflow question, thank you

Nick (Cloud Platform Support)

unread,
Aug 17, 2015, 6:53:14 PM8/17/15
to Google App Engine
Hey Chris,

Thanks for linking back. I'll be following your question.

Best wishes,

Nick
Reply all
Reply to author
Forward
0 new messages