Skip to content
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

UnauthorizedRegistration error #23

Closed
maephisto opened this issue Nov 25, 2016 · 10 comments
Closed

UnauthorizedRegistration error #23

maephisto opened this issue Nov 25, 2016 · 10 comments

Comments

@maephisto
Copy link

I'm doing this tutorial using the code samples, and having folder "08-completed" running in my Chrome WebServer.
But when I try to use the companion app at https://web-push-codelab.appspot.com/ or use web-push module on my local machine I get a "UnauthorizedException" error.

$ web-push send-notification --endpoint=https://fcm.googleapis.com/fcm/send/XXXX
Error sending push message:
{ [WebPushError: Received unexpected response code]
  name: 'WebPushError',
  message: 'Received unexpected response code',
  statusCode: 400,
  headers:
   { 'content-type': 'text/html; charset=UTF-8',
     date: 'Fri, 25 Nov 2016 08:54:08 GMT',
     expires: 'Fri, 25 Nov 2016 08:54:08 GMT',
     'cache-control': 'private, max-age=0',
     'x-content-type-options': 'nosniff',
     'x-frame-options': 'SAMEORIGIN',
     'x-xss-protection': '1; mode=block',
     server: 'GSE',
     'alt-svc': 'quic=":443"; ma=2592000; v="36,35,34"',
     'accept-ranges': 'none',
     vary: 'Accept-Encoding',
     connection: 'close' },
  body: '<HTML>\n<HEAD>\n<TITLE>UnauthorizedRegistration</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>UnauthorizedRegistration</H1>\n<H2>Error 400</H2>\n</BODY>\n</HTML>\n' }

Same error I get form the companion app.

Any idea what am I missing / doing wrong?

@dev-mraj
Copy link

dev-mraj commented Dec 1, 2016

Same error.
there are many people getting same errors.
web-push-libs/web-push#254

its 6 days, no response on this issue? anyone listening here?

@gauntface
Copy link
Contributor

The main thing to check when doing this is to ensure the vapid keys you use with web push OR the companion app is matching with the subscription

I'll update the companion app to the latest web push incase that's the issue.

@JakeCallery
Copy link

JakeCallery commented Dec 19, 2016

Same issue here.
Seems to work fine in Firefox (currently 50.1.0 / also worked in 47.0.2)with the mozilla endpoint:
https://updates.push.services.mozilla.com/wpush/v2/

Does not work in chrome (55.0.2883.87 (Official Build) m (32-bit)) with Firebase endpoint:
https://fcm.googleapis.com/fcm/send/

Others had mentioned setting the vapid keys to expire after 12hours instead of 24, and some had some luck with setting the server clock back a few minutes.

Any thoughts on what we can do for chrome here?

Edit: Forgot to mention that both browsers are the windows builds.

@JakeCallery
Copy link

Sorry guys, I'm in idiot. I was printing the endpoint object to the console and pasting from there. the chrome console truncated it (had "..." somewhere in the middle) where as the firefox console did not.
It works as advertised for me now. Sorry for the confusion.

@gauntface
Copy link
Contributor

gauntface commented Jan 11, 2017

Argh - I hate that truncation. I raised an issue with Chrome to fix that but still haven't seen it land :(

I'm going to close this bug for now as I just updated web-push to a newer version that should help with this if the expiration was the issue.

@ahimta
Copy link

ahimta commented Jan 30, 2017

I faced the very same issue of truncated text in the Chrome's console. However, I made the right decision of taking a break right after it happened to me rather than spending unnecessarily many hours on it.

Please do include a note in the code lab about this!

@gauntface
Copy link
Contributor

If I don't print the subscription to the terminal, do you think people would copy from the web page UI instead?

@ahimta
Copy link

ahimta commented Jan 30, 2017

I don't understand. Perhaps you're talking about running the companion site locally; I've only done the frontend part and intend to implement the backend later. If I wasn't clear earlier, I had already managed to push notifications from the companion site successfully by the time I wrote the first comment.

One final note, I didn't work through the codelab. I just started adding the functionality to an existing app right away (and it worked).

@gauntface
Copy link
Contributor

So, what I mean is that where you said "I faced the very same issue of truncated text in the Chrome's console." one fix for this is to simply not show the subscription in the console, forcing everyone to grab the subscription from the page itself - Which I've made the change and submitted it to the codelab.

@ahimta
Copy link

ahimta commented Jan 31, 2017

That would definitely fix the issue, assuming the developer is working through the codelab (probably most). But in my case, I didn't go through the codelab and added the functionality to an existing app - I just finished my initial backend implementation for push notifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants