When using this library I am getting Invalid VAPID token. This occurs randomly sometimes you won't get it at all. Sometimes you do.
[main] DEBUG *.*.*.PushService - header Authorization WebPush <jwt>
16:43:57.748 [main] DEBUG *.*.*.PushService - header Content-Encoding aesgcm
16:43:57.748 [main] DEBUG *.*.*.PushService - header Encryption salt=<salt>
16:43:57.748 [main] DEBUG *.*.*.PushService - header TTL 2419200
16:43:57.748 [main] DEBUG *.*.*.PushService - header Crypto-Key dh=BHGQ****dw=;p256ecdsa=BB_****
16:43:57.748 [main] DEBUG *.*.*.PushService - header Content-Type application/octet-stream
The response I am getting is
{"origin":"remote","type":"response","correlation":"b7b0107273db5d1e","duration":2227,"protocol":"HTTP/1.1","status":401,"headers":{"Connection":["keep-alive"],"Content-Length":["296"],"Content-Type":["application/json"],"Date":["Sat, 02 Jul 2022 14:44:00 GMT"],"Server":["nginx"]},"body":{"code":401,"errno":109,"error":"Unauthorized","message":"Invalid VAPID token: A value in the vapid claims is either missing or incorrectly specified (e.g. \"exp\":\"12345\" or \"sub\":null). Please correct and retry.","more_info":"http://autopush.readthedocs.io/en/latest/http.html#error-codes"}}
Subscription subscription = new Subscription();
subscription.endpoint = endpoint;
subscription.keys = new Keys();
subscription.keys.auth = auth;
subscription.keys.p256dh = p256dh;
ObjectMapper mapper = new ObjectMapper();
var webPushMessage = new WebPushMessage();
webPushMessage.setBody("A new document was uploaded");
webPushMessage.setTitle("Document uploaded");
var notification = new Notification(subscription, mapper.writeValueAsString(webPushMessage));
var logbook = createLogbook();
var client = httpClient(logbook);
var pushService = new PushService(keys.getPublicKey(), keys.getPrivateKey(), client);
pushService.send(notification);
When using this library I am getting
Invalid VAPID token. This occurs randomly sometimes you won't get it at all. Sometimes you do.The response I am getting is
{"origin":"remote","type":"response","correlation":"b7b0107273db5d1e","duration":2227,"protocol":"HTTP/1.1","status":401,"headers":{"Connection":["keep-alive"],"Content-Length":["296"],"Content-Type":["application/json"],"Date":["Sat, 02 Jul 2022 14:44:00 GMT"],"Server":["nginx"]},"body":{"code":401,"errno":109,"error":"Unauthorized","message":"Invalid VAPID token: A value in the vapid claims is either missing or incorrectly specified (e.g. \"exp\":\"12345\" or \"sub\":null). Please correct and retry.","more_info":"http://autopush.readthedocs.io/en/latest/http.html#error-codes"}}