Google Api oauth2callback timeout/404/error

Mon 18 February 2013
By balrok
Contents

    A strange bug which wasn't found on the net yet and which I want to report here. I use the Google Calendar Api for one site. Testing locally was perfectly fine (btw: you can add 127.0.0.1 into the allowed domains for this). But after deploying it on the server the oauth2callback always timed out and crashed my php-fpm.

    The problem was, that 'wget http://google.com' resolved an ipv6 address and then had to endlessly wait for a connection. The solution was to simply use the ipv4 address. So first I started to pollute my /etc/hosts until I later stumbled upon [disable ipv6 in php_curl][].

    And the final patch looked like this

    diff --git a/protected/extensions/GoogleApis/lib/google-api-php-client/src/io/Google_CurlIO.php b/protected/extensions/GoogleApis/lib/google-api-php-client/src/io/Google_CurlIO.php
    index 65352f2..3b9e7eb 100644
    --- a/protected/extensions/GoogleApis/lib/google-api-php-client/src/io/Google_CurlIO.php
    +++ b/protected/extensions/GoogleApis/lib/google-api-php-client/src/io/Google_CurlIO.php
    @@ -40,6 +40,8 @@ class Google_CurlIO implements Google_IO {
           CURLOPT_SSL_VERIFYPEER => true,
           CURLOPT_HEADER => true,
           CURLOPT_VERBOSE => false,
    +         CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
       );
    
       /**
    

    (I guess the patching could be done outside the lib-folder too - but I don't need an enterprise-solution for this particular site)

    Hopefully I can help somebody else here with this :)

    Commentaires: