msgraph: add metadata to users to connect with default calendar

This commit is contained in:
2022-05-06 10:13:32 +02:00
parent 5331f1becc
commit 9935af0497
9 changed files with 181 additions and 12 deletions

View File

@@ -12,6 +12,8 @@ declare(strict_types=1);
namespace Chill\CalendarBundle\Synchro\Connector\MSGraph;
use Chill\MainBundle\Redis\ChillRedis;
use League\OAuth2\Client\Token\AccessTokenInterface;
use TheNetworg\OAuth2\Client\Provider\Azure;
use TheNetworg\OAuth2\Client\Token\AccessToken;
class MachineTokenStorage
@@ -20,14 +22,29 @@ class MachineTokenStorage
private ChillRedis $chillRedis;
public function __construct(ChillRedis $chillRedis)
private Azure $azure;
private ?AccessTokenInterface $accessToken = null;
public function __construct(Azure $azure, ChillRedis $chillRedis)
{
$this->azure = $azure;
$this->chillRedis = $chillRedis;
}
public function getToken(): AccessToken
public function getToken(): AccessTokenInterface
{
return unserialize($this->chillRedis->get(self::KEY));
if (null === $this->accessToken || $this->accessToken->hasExpired()) {
$this->accessToken = $this->azure->getAccessToken('client_credentials', [
'scope' => 'https://graph.microsoft.com/.default',
]);
}
dump($this->accessToken);
return $this->accessToken;
//return unserialize($this->chillRedis->get(self::KEY));
}
public function storeToken(AccessToken $token): void