requestStack->getSession()->get(self::MS_GRAPH_ACCESS_TOKEN, null); if (null === $token) { throw new \LogicException('unexisting token'); } if ($token->hasExpired()) { $token = $this->azure->getAccessToken('refresh_token', [ 'refresh_token' => $token->getRefreshToken(), ]); $this->setToken($token); } return $token; } public function hasToken(): bool { return $this->requestStack->getSession()->has(self::MS_GRAPH_ACCESS_TOKEN); } public function setToken(AccessToken $token): void { $this->requestStack->getSession()->set(self::MS_GRAPH_ACCESS_TOKEN, $token); } }