@@ -408,7 +408,7 @@ And here is the controller::
408
408
// src/Controller/DiscoverController.php
409
409
namespace App\Controller;
410
410
411
- use Lcobucci\JWT\Builder ;
411
+ use Lcobucci\JWT\Configuration ;
412
412
use Lcobucci\JWT\Signer\Hmac\Sha256;
413
413
use Lcobucci\JWT\Signer\Key;
414
414
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -423,11 +423,14 @@ And here is the controller::
423
423
{
424
424
$hubUrl = $this->getParameter('mercure.default_hub');
425
425
$this->addLink($request, new Link('mercure', $hubUrl));
426
-
427
- $token = (new Builder())
428
- // set other appropriate JWT claims, such as an expiration date
426
+
427
+ $key = Key\InMemory::plainText('mercure_secret_key'); // don't forget to set this parameter! Test value: !ChangeMe!
428
+ $configuration = Configuration::forSymmetricSigner(new Sha256(), $key);
429
+
430
+ $token = $configuration->builder()
429
431
->withClaim('mercure', ['subscribe' => ["http://example.com/books/1"]]) // can also be a URI template, or *
430
- ->getToken(new Sha256(), new Key($this->getParameter('mercure_secret_key'))); // don't forget to set this parameter! Test value: !ChangeMe!
432
+ ->getToken($configuration->signer(), $configuration->signingKey())
433
+ ->toString();
431
434
432
435
$response = $this->json(['@id' => '/demo/books/1', 'availability' => 'https://schema.org/InStock']);
433
436
$cookie = Cookie::create('mercureAuthorization')
0 commit comments