Google API gives Curl Error

84
August 11, 2018, at 06:40 AM

I have a stand-alone PHP program (not part of a web server) that needs to access Google Sheets and I keep getting the infamous curl error 6. I have tried adding a certificate path to the PHP.INI file, I have tried turning it off in the client configuration and nothing is working. Can anyone suggest anything else that might fix the problem?

class GoogleFunctions
 {
    private $client;
    private $accessToken;
    private $sheetsService;
    private $driveService;
    /* 
    * Establish our connection with Google and create Drive and Sheet clients
    * */
    public function initialize() {
        /*
        * We need to get a Google_Client object first to handle auth and api calls, etc.
        */
        //$http = new GuzzleHttp\Client(['verify' => './Certificates/cacert.pem']);
        //$http = new GuzzleHttp\Client(['verify' => 'C:\Development\EDPS\EDPS\Development\.credentials\cacert.pem']);
        $http = new GuzzleHttp\Client(['verify' => false]);
        $this->client = new Google_Client();
        $this->client->setHttpClient($http);
        $this->client->setApplicationName('EDPS');
        $this->client->setScopes(Google_Service_Drive::DRIVE_FILE or Google_Service_Sheets::SPREADSHEETS);
        $this->client->setAuthConfig('sheets_api_secret.json');
        $this->client->setAccessType('offline');
        $this->refreshAccessToken();
        $accessToken = $this->client->fetchAccessTokenWithAssertion()["access_token"];
        /* ServiceRequestFactory::setInstance(new DefaultServiceRequest($accessToken)); */
        $this->client->setAccessToken($accessToken);
        /*
        * Get our two services for accessing folders and sheets.
        */
        $this->sheetsService = new \Google_Service_Sheets($this->client);
        $this->driveService = new Google_Service_Drive($this->client);
}

. . .

private function refreshAccessToken() {
    if ($this->client->isAccessTokenExpired()) {
        $this->client->refreshTokenWithAssertion();
    }
}

}

The code always dies in the above function refreshTokenWithAssertion with the curl error 60. I have followed several articles which suggest providing your own Guzzle client (as shown above) but nothing seems to work. What is really maddening about this is that the code works fine on one Windows PC but when transferred to a development laptop for working with the client it stopped working. I am running PHP 5.6.36 with the Google 2 api client. Any other suggestions, please?

READ ALSO
call soap in php using xml

call soap in php using xml

it is my first time that I was assigned to implement a soap call in phpBefore implementing it, I used postman where I inserted the following xml request

118
Laravel Basic Auth- Invalid Credentials Error in json

Laravel Basic Auth- Invalid Credentials Error in json

I am using basic auth in my apiWhen I enter a wrong credential, it throws

256