pusher / push-notifications-web

Beams Browser notifications
MIT License
39 stars 20 forks source link

`Token Error` with client.start() #149

Open sudkumar opened 7 months ago

sudkumar commented 7 months ago

I had successfully integrated the beam on a web application. But from past few weeks, I am receiving an error when registering a new device. I am on version 1.1.0 (same as when I first integrated) of the web SDK and I have integrated the pusher service worker in my existing service worker (was created by create-react-app). When I try to call the client.start(), there are two network requests.

  1. https://`id`.pushnotifications.pusher.com/device_api/v1/instances/`id`/web-vapid-public-key
  2. https://`id`.pushnotifications.pusher.com/device_api/v1/instances/`id`/devices/web

The first network request successfully returns a vapidPublicKey. The second request is failing with status code of 401 and JSON response as following.

{
    "error": "Token error",
    "description": "Subscription is not registered with the given push service"
}

Here is the sample code for device registration:

const client = new Client({ instanceId, serviceWorkerRegistration }) // create client
await client.start() // register the device
// register the user with token provider...

Any pointer or guidelines are much appreciated.

Thank you.

P.S.: Even if I go the extract same commit as when I first integrated the pusher beam, I am getting the same error.

benw-pusher commented 7 months ago

I'm not able to replicate this. Could you share more about the environment - what OS / Browser are you using? Are all devices impacted or just this one?

Do you see the same if you clear all caches of the site/browser and retry?

sudkumar commented 7 months ago

@benw-pusher Thank you for your reply.

what OS / Browser are you using?

Are all devices impacted or just this one?

No. I tried on my Android phone, and it is working. I checked on Google Chrome on my colleague's Windows OS device, and it was working. But when I tried in Microsoft Edge on Window OS, it showed the same error.

Do you see the same if you clear all caches of the site/browser and retry?

Yes. I cleared all the storage data for the site on my device, but it was still failing.


Looks like it has something to do with the Microsoft Edge! Please let me know if you are able to replicate it on MS Edge.

JonathanCallewaert commented 7 months ago

Is there any progress on this? We have the same problem on Edge and is pretty critical too us @benw-pusher In all other browsers, it works.

KevinDenys commented 7 months ago

image

image

I have the same issue on Microsoft Edge

benw-pusher commented 7 months ago

I have been able to replicate on Edge, this has been escalated to our engineering team. It is possible a recent update to Edge caused this, but I haven't been able to verify at this stage.

JonathanCallewaert commented 7 months ago

Hi @benw-pusher , I was wondering if there are any updates on this?

nikz commented 6 months ago

Hi there,

We're also seeing the same issue in Edge:

{
    "error": "Token error",
    "description": "Subscription is not registered with the given push service"
}

Everything works fine in Chrome and Firefox - just not Edge. The same code is running.

I should note I'm also using Edge 122.0.2365.92 on macOS (14.3.1)

standingdreams commented 3 months ago

Hey team. Any update on the issue with Microsoft Edge?

itsmill3rtime commented 2 months ago

I have been able to replicate on Edge, this has been escalated to our engineering team. It is possible a recent update to Edge caused this, but I haven't been able to verify at this stage.

@benw-pusher I have been trying to fix this same error for 2 days now on edge. Just came across this thread and sad to see there has been no updates on it

hmerritt commented 3 weeks ago

Debugging this and have a few findings (sadly no fix yet):

https://github.com/pusher/push-notifications-web/blob/13c861e66c60a498cdaa9c170574f63f6a8a74de/src/push-notifications.js#L183

Contents of edge JWT (note the wns2-ln2p.notify.windows.com endpoint)

{
  "endpoint": "https://wns2-ln2p.notify.windows.com/w/?token=...",
  "expirationTime": null,
  "keys": {
    "p256dh": "...",
    "auth": "..."
  }
}

Contents of chrome JWT (note the fcm.googleapis.com endpoint)

{
  "endpoint": "https://fcm.googleapis.com/fcm/send/...",
  "expirationTime": null,
  "keys": {
    "p256dh": "...",
    "auth": "..."
  }
}

EDIT: I have found other people have had the same issue with notify.windows, specifically the issue seems to be the token encoding needed to be EXACT.

https://github.com/web-push-libs/web-push-php/issues/233#issuecomment-1078835622


Would be awesome to see some progress with this bug 🙏

jcbdev commented 3 weeks ago

@hmerritt is correct and this issue severely affects a platform we have in production.

Many corporate clients mandate edge browser and this alienates a large proportion of users. This issue has been open 7 months and does not fill me with confidence that this platform is in anyway stable for production use. If this continues we will not continue our rollout of pusher across our platforms and move to another supplier.

Are you able to give a proper update on the status of this issue?