I want to configure my Symfony4 application to read and send e-mails using the msgraph-sdk-php library.
My first experience was this piece of code:
$guzzle = new \GuzzleHttp\Client();
$url = 'https://login.microsoftonline.com/' . $tenantId . '/oauth2/token?api-version=1.0';
$token = json_decode($guzzle->post($url, [
'form_params' => [
'client_id' => $clientId,
'client_secret' => $clientSecret,
'resource' => 'https://graph.microsoft.com/',
'grant_type' => 'client_credentials',
],
'verify' => false
])->getBody()->getContents());
$accessToken = $token->access_token;
$graph = new Graph();
$graph->setAccessToken($accessToken);
try {
$user = $graph->createRequest("GET", "/me")
->setReturnType(User::class)
->execute();
} catch (GraphException $e) {
$user=(object) ['getGivenName'=>$e->getMessage()];
}
return "Hello, I am $user->getGivenName() ";
But then Symfony shows me an exception page with this message:
cURL error 60: SSL certificate problem: unable to get local issuer certificate
What should I do to overcome this?