googleapis/google-auth-library-php

SSL certificate problem: unable to get local issuer certificate for https://oauth2.googleapis.com/token

Closed this issue · 1 comments

Hi,
I'm trying to authenticate before getting my location reviews :

use Google\Auth\ApplicationDefaultCredentials;
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;

// specify the path to your application credentials
putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/my/credentials.json');

// define the scopes for your API call
$scopes = ['https://www.googleapis.com/auth/business.manage'];

// create middleware
$middleware = ApplicationDefaultCredentials::getMiddleware($scopes);
$stack = HandlerStack::create();
$stack->push($middleware);

// create the HTTP client
$client = new Client([
  'handler' => $stack,
  'base_uri' => 'https://mybusiness.googleapis.com',
  'auth' => 'google_auth'  // authorize all requests,
  // 'cert' => 'C:\WORKSPACE\projects\perso\cacert.pem',
  'verify' => 'C:\WORKSPACE\projects\perso\cacert.pem',
]);

// make the request
$response = $client->get('v4/accounts/xxxx/locations/yyyy/reviews');

// show the result!
print_r((string) $response->getBody());

My json file is like this:

{
  "type": "service_account",
  "project_id": "xxxx",
  "private_key_id": "xxxx",
  "private_key": "-----BEGIN PRIVATE KEY-----xxxx-----END PRIVATE KEY-----\n",
  "client_email": "xxxx@xxxx.iam.gserviceaccount.com",
  "client_id": "xxxx",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/xxxx%40xxxx.iam.gserviceaccount.com",
  "universe_domain": "googleapis.com"
}

I get the following error:

SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://oauth2.googleapis.com/token

Can anyone have an idea ?

This seems like an issue with your local environment. This library does not handle SSL certificates. You may have better luck looking for support on Stack Overflow.