zaru / webpush

webpush, Encryption Utilities for Web Push protocol
MIT License
394 stars 73 forks source link

Authorization error 401 from chrome as well as firefox #81

Closed ranjanM123 closed 5 years ago

ranjanM123 commented 5 years ago
collimarco commented 5 years ago

The error says that exp field inside JWT payload is more than 24 hours and that you must decrease it.

The expiration value is defined here:

https://github.com/zaru/webpush/blob/6aed6657a40bf40dbdf2ff617c3370507ae3fd64/lib/webpush/request.rb#L117

Probably you are passing an expiration option to Webpush.payload_send: can you check that? If you find that, simply remove that option or decrease the value.

Otherwise the problem is here:

https://github.com/zaru/webpush/blob/6aed6657a40bf40dbdf2ff617c3370507ae3fd64/lib/webpush/request.rb#L103

Your server time is not correct (e.g. not UTC or not precise) and thus you get an error.

You can also decrease the vapid: expiration: option to 12 hours for example, as a workaround for your imprecise server time.

rossta commented 5 years ago

Thanks for the response, @collimarco.

ranjanM123 commented 5 years ago

Thanks for the response, @collimarco.