getSession()->set('azure_return_path', $request->query->get('returnPath', '/')); return $this->clientRegistry ->getClient('azure') // key used in config/packages/knpu_oauth2_client.yaml ->redirect(['https://graph.microsoft.com/.default', 'offline_access'], []); } #[Route(path: '/connect/azure/check', name: 'chill_calendar_remote_connect_azure_check', schemes: 'https')] public function connectAzureCheck(Request $request): Response { /** @var Azure $client */ $client = $this->clientRegistry->getClient('azure'); try { /** @var AccessToken $token */ $token = $client->getAccessToken([]); $this->MSGraphTokenStorage->setToken($token); } catch (IdentityProviderException $e) { throw $e; } return new RedirectResponse($request->getSession()->remove('azure_return_path', '/')); } }