Skip to content

Edge - *always* gets 401 Unauthorized #209

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

Closed
8 of 15 tasks
nunoperalta opened this issue Jan 30, 2019 · 4 comments
Closed
8 of 15 tasks

Edge - *always* gets 401 Unauthorized #209

nunoperalta opened this issue Jan 30, 2019 · 4 comments

Comments

@nunoperalta
Copy link

Please confirm the following:

  • I have read the README entirely
  • I have verified in the issues that my problem hasn't already been resolved

Setup

Please provide the following details, the more info you can provide the
better.

  • Operating System: Linux
  • PHP Version: 7.2
  • web-push-php Version: 5.1.0

Please check that you have installed and enabled these PHP extensions :

  • gmp
  • mbstring
  • curl
  • openssl

Please select any browsers that you are experiencing problems with:

  • Chrome
  • Firefox
  • Firefox for Mobile
  • Opera for Android
  • Samsung Internet Browser
  • Edge

Please specify the versions (i.e. Chrome Beta, Firefox Beta etc).

Users seem to be using Microsoft Edge 17.17134 on Windows 10

Please explain what behaviour you are seeing.

When sending notifications, always get back:
"Client error: POST https://dm3p.notify.windows.com/w/?token=(...) resulted in a 401 Unauthorized response"

Please explain what you expected to happen

Notification to be sent successfully

Features Used

  • VAPID Support
  • GCM API Key
  • Sending with Payload

Example / Reproduce Case

I receive from user:

{"endpoint":"https://dm3p.notify.windows.com/w/?token=<348 chars>","expirationTime":1551451893000,"keys":{"auth":"<22 chars>","p256dh":"<87 chars>"}}

Content Encoding: aes128gcm

This is properly saved in database, so it's not the same issue as #174

Same code works well for all other browsers:

$auth = array(
	'VAPID' => array(
		'subject' => 'mailto:[email protected]',
		'publicKey' => PUSH_PUBLIC,
		'privateKey' => PUSH_PRIVATE
	)
);
$defaultOptions = array(
);
$timeout = 5; // seconds
$clientOptions = array(
	\GuzzleHttp\RequestOptions::ALLOW_REDIRECTS => false
);
$webPush = new WebPush($auth, $defaultOptions, $timeout, $clientOptions);

		$subcription = Subscription::create([
			'endpoint' => $row['endpoint'],
			'publicKey' => $row['key_p256dh'],
			'authToken' => $row['key_auth'],
			'contentEncoding' => $row['content_encoding']
		]);
		$webPush->sendNotification(
			$subcription,
			json_encode($json)
		);
@ozgurhangisi
Copy link

Hi,

We can send notifications to Edge using this library. Windows had some bugs on older versions. We can send push to Windows Version 1803(OS Build 17134.407) successfully. Can you get any other notifications from other websites (for edge browser) on the same device ? Is it possible to try web push on new windows and edge versions ?

@nunoperalta
Copy link
Author

I would love to test by myself, but the thing is that I never succeeded actually subscribing on Edge, in every Windows 10 version I've had so far.

I'm currently on the latest stable version of Windows (October upgrade + updates).

Here's a bit of code that works for ALL browsers except Edge:

SW.Push.ServiceWorkerRegistration.pushManager.subscribe({
	userVisibleOnly: true,
	applicationServerKey: urlBase64ToUint8Array(PUSH_PUBLIC)
})
.then(function(subscription) {
	SW.Push.SubscribeToServer();
})
.catch(function(err) {
	console.errorlog('Failed to subscribe the user', err);
});

And I simply get an "AbortError" (in the "catch" block), and I have no clue why...

[object DOMException]: {code: 20, message: "AbortError", name: "AbortError"}
code: 20
message: "AbortError"
name: "AbortError"

I've tried many different examples, even one provided by Microsoft/Edge themselves.
Notifications are enabled on Edge, for this website.

@Minishlink
Copy link
Member

@nunoperalta This is a known bug that can be reproductible on their own demo website

@Interghost
Copy link

I realize this is not actually related to this project, but has anyone managed to get it working on Edge in some way?

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

4 participants