web-push-php: 401 Unauthorized: authorization header must be specified
- I have read the README entirely
- I have verified in the issues that my problem hasn’t already been resolved
Setup
- Operating System: Linux
- PHP Version: 7.4
- web-push-php Version: <6.0.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:
- CLI
Features Used
- VAPID Support
- Sending with Payload
Problem
As of v6.0.0, I get a 401 Unauthorized when sending a push notification:
Client error:
POST https://fcm.googleapis.com/fcm/send/....resulted in a401 Unauthorizedresponse: authorization header must be specified.
I’m using minishlink/web-push-bundle and everything worked perfectly, but upgrading to v6 gives this problem. For Windows clients I get a curl timeout, for FCM I get this 401.
Any idea what causes this problem?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (4 by maintainers)
That worked for me in Chrome. I just needed to add the VAPID to the constructor as you mentioned and the encoding to the subscription .
Here is my code:
Thanks @veldenb for pointing out. I’ve created a PR in the bundle repository.
I think it might be a bug in the bundle: https://github.com/Minishlink/web-push-bundle/issues/19#issue-728201518 In my case the VAPID-keys where not added to the library.
I have the same problem with v6.0.1
application.js
push.php