If any of you has trouble using PECL http or just prefer using cURL, I have put an example in PHP of getting the access token AND refresh token: http://www.jamesattard.com/2013/04/generate-google-api-refresh-and-access.html