zaru / webpush

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

unexpected, temporary 401 responses from Google #70

Closed mohamedhafez closed 5 years ago

mohamedhafez commented 5 years ago

Just since the last few days, I've been getting a lot of temporary 401 HTML responses from just Google, however retrying a few minutes later works with no issue. the fact that its an HTML response makes me think it might be a glitch on Google's end? here's an example response:

<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 401 (Unauthorized)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/logos/errorpage/error_logo-150x54.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/logos/errorpage/error_logo-150x54-2x.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/logos/errorpage/error_logo-150x54-2x.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/logos/errorpage/error_logo-150x54-2x.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
  </style>
  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
  <p><b>401.</b> <ins>That’s an error.</ins>
  <p>  <ins>That’s all we know.</ins>

If you guys agree this is just some kind of temporary glitch, perhaps we shouldn't be raising an Unauthorized error at https://github.com/zaru/webpush/blob/master/lib/webpush/request.rb#L33 that would cause the receiver to think that the registration token is no longer valid?

mohamedhafez commented 5 years ago

Oh and P.S. this seems to be only happening for targets where I'm not using VAPID (I haven't noticed this issue for targets for which I am using VAPID, or at least not yet)

mohamedhafez commented 5 years ago

The issue was getting worse so I looked in to it more, it was only occurring for endpoints with https://android.googleapis.com/gcm/send that we replace with https://gcm-http.googleapis.com/gcm. It seems that both those endpoints are being shut down at the end of this May, so I'd say its not worth the effort to deal with this. Personally I just emailed those users affected and asked them to re-enable the desktop notifications so they could get the new fcm endpoint, and don't seem to be experiencing the issue any more.