0

I am facing this error while setting up Google+ OAuth when it redirects to the callback page and I don't know how to resolve it I am using google api php client v2.2.0

Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 77: error setting certificate verify locations: CAfile: C:\xampp\apache\bin\curl-ca-bundle.crt CApath: none (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) in C:\xampp\htdocs\phpoauth\GoogleApi\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:187 Stack trace: #0 C:\xampp\htdocs\phpoauth\GoogleApi\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(150): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array) #1 C:\xampp\htdocs\phpoauth\GoogleApi\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(103): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory)) #2 C:\xampp\htdocs\phpoauth\GoogleApi\vendor\guzzlehttp\guzzle\src\Handler\CurlHandler.php(43): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handle in C:\xampp\htdocs\phpoauth\GoogleApi\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 187

this is what I have tried in php config.php

<?php 
session_start();
require_once "GoogleApi/vendor/autoload.php";

$gclient = new Google_Client();
$gclient->setClientId("myClientID");
$gclient->setClientSecret("myClientSecret");
$gclient->setApplicationName("NC Login Tutorial");
$gclient->setRedirectUri("http://localhost/phpoauth/g-callback.php");
$gclient->addScope("https://www.googleapis.com/auth/userinfo.email");
?>

g-callback.php

<?php 
require_once "config.php";
if(isset($_GET['code'])){
    $token = $gclient->fetchAccessTokenWithAuthCode($_GET['code']);
    $_SESSION['access_token'] = $token;
}
$oAuth = new Google_Service_Oauth2($gclient);
$userData = $oAuth->userinfo_v2_me->get();
echo "<pre>";
var_dump($userData);
?>

besides this problem is there an easy way to set up an OAuth on your website which is secure as well?

  • It looks like there is an issue making your server unable to communicate with Google. Have you tried this? https://stackoverflow.com/questions/3160909/how-do-i-deal-with-certificates-using-curl-while-trying-to-access-an-https-url – Nicolapps Jul 19 '20 at 14:32
  • @Nicolapps thank you very much it solved my problem, but is it just with the localhost or we can face the same issue on a live server as well? – new_dev Jul 19 '20 at 15:58
  • how did you install gogole api? manual or via composer? – zeus2026 Jul 19 '20 at 16:12
  • @zeus2026 I did it manually – new_dev Jul 19 '20 at 16:14
  • First change your scope, I assume that you one to get the email of the user right? change it into this $gclient->addScope('email'); then manually locate or include the app path vendor/google/apiclient/src/Google/Client.php, if error persist try to reinstall via composer – zeus2026 Jul 19 '20 at 16:21
  • @new_dev It’s a configuration issue, so it could theory also happen on a remove server (but once the server is set up properly it wouldn’t break on its own). – Nicolapps Jul 19 '20 at 19:35
  • @Nicolapps ok, thank you – new_dev Jul 19 '20 at 20:01

0 Answers0