【发布时间】:2021-07-17 13:52:27
【问题描述】:
我使用 MAMP 作为本地开发环境。我想实施 Google 身份验证 - 但不断收到此 SSL 错误。
- 正如其他 SO 主题所建议的,我已经在我的 PHP.ini 文件中添加了这行代码:
curl.cainfo ="C:/MAMP/bin/php/php7.4.1/extras/ssl/cacert.pem"
- 并从此处添加最新的 CA 证书:https://curl.se/docs/caextract.html 在我的 PHP SSL 文件夹中:C:\MAMP\bin\php\php7.4.1\extras\ssl
任何想法如何在我的本地环境中传递此 SSL 错误?
这是代码:
$google_client = new \Google_Client();
$google_client->setClientId($clientID);
$google_client->setClientSecret($clientSecret);
$google_client->setRedirectUri($redirectUri);
$google_client->addScope("email");
$google_client->addScope("profile");
if($this->request->getVar('code')){
$token = $google_client->fetchAccessTokenWithAuthCode($this->request->getVar('code'));
if(!isset($token['error'])){
$google_client->setAccessToken($token['access_token']);
$this->session->set('access_token', $token['access_token']);
//get Google profile data
$google_service = new \Google_Service_Oatuth2($google_client);
$data = $google_service->userinfo->get();
print_r($data);
【问题讨论】:
标签: php ssl curl localhost mamp