-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid VAPID token: A value in the vapid claims is either missing or incorrectly specified #195
Comments
Ended up copying the lib and changing the jose library to the common nimbus and those issues are now gone. |
@atkawa7 I have the same problem as you, but I'm not sure I understood your solution. "changing the jose library to the common nimbus" - did you change it in the source code and re-built the jar? |
@aistomin Yes that's what I did. I think you only need to changed three or 4 lines and exception. Something along these lines var builder = new Builder();
builder.audience(notification.getOrigin());
builder.expirationTime(Date.from(Instant.now().plus(12, ChronoUnit.HOURS)));
if (getSubject() != null) {
builder.subject(getSubject());
}
var payload = new Payload(builder.build().toJSONObject());
var jwsObject = new JWSObject(new JWSHeader(ES256), payload);
if (privateKey instanceof ECPrivateKey ecPrivateKey) {
var jwsSigner = new ECDSASigner(ecPrivateKey);
jwsObject.sign(jwsSigner);
} else {
throw new JOSEException("Expected ECPrivateKey");
} |
@atkawa7 sorry, one more question, did you use https://mvnrepository.com/artifact/com.nimbusds/nimbus-jose-jwt/9.23 ? |
@aistomin Yes that's correct |
@atkawa7 Sorry, Please Provide code line where to use? I have same problem. Especially imports |
@atkawa7 Hi. Could you expand on your answer? Does this mean you removed the jwt code and replaced it with a 3rd party to generate the token? If so, do you know why the current code is not building a token Mozilla likes? I dont get the error you were getting with chrome but I do trying to push to the Firefox/Mozilla push service. I wonder what made this stop working |
@umutawakil Yes that is correct. I removed jose4j and replaced it with nimbus-jose-jwt. @chamallamudi-gopikrishna import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.JWSHeader;
import com.nimbusds.jose.JWSObject;
import com.nimbusds.jose.Payload;
import com.nimbusds.jose.crypto.ECDSASigner;
import com.nimbusds.jwt.JWTClaimsSet.Builder;
import static com.nimbusds.jose.JWSAlgorithm.ES256; |
I have the same problem, I tried with the solution explained using nimbus, here is the code
The error in firefox is still a 401 (Invalid VAPID tokens: A value in the vapid claims is either missing or incorrectly specified) |
@sbodmer for me it turned out that the problem was not in the library at all. From experience I found out that Firefox requires |
Bingo, I added the "sub" part and now it works, thanks a lot my friend ;^) |
@sbodmer I'm glad it helped.
Yes, absolutely. Looks like it's either a Firefox bug, or intentional violation of the protocol :) |
You just have to add the Subject in your push service, nothing else changes... Here is what I changed and solved the problem (but it was a long time ago, I'm not entirely sure...) What was odd is that in the specification the "Subject" is not mandatory, but Firefox (not chrome) makes it mandatory, so they are violating the specifications. Good luck |
Just to add to this, I found another Firefox issue. The |
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
The text was updated successfully, but these errors were encountered: