mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-28 09:34:59 +00:00
msgraph: add metadata to users to connect with default calendar
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user