webpush-java icon indicating copy to clipboard operation
webpush-java copied to clipboard

403 Forbidden for Chrome

Open zhangms143 opened this issue 1 year ago • 1 comments

I'm trying to use web-push to push messages, and it works fine on Microsoft Chrome, but Google Chrome gets error 403 Forbidden.(Use the same key pair)

return message: the VAPID credentials in the authorization header do not correspond to the credentials used to create the subscriptions.

How do I fix it?

zhangms143 avatar Mar 16 '24 10:03 zhangms143

I had the same issue, and found a fix on the problem and replaced the code in the following lines

---- AbstractPushService.java ----
Line 211:  headers.put("Crypto-Key", headers.get("Crypto-Key") + ";p256ecdsa=" + Base64.getUrlEncoder().withoutPadding().encodeToString(pk));
Line 212:  headers.put("Crypto-Key", "p256ecdsa=" + Base64.getUrlEncoder().encodeToString(pk));

Thor-Erling avatar May 14 '24 19:05 Thor-Erling