firebase/quickstart-js

messaging.getToken response http status 401

WangMosquito opened this issue · 4 comments

Step 1: Describe your environment

  • Operating system: windows 10
  • Browser: Chrome Version 91.0.4472.114
  • Firebase SDK version: 8.6.8

Step 2: Describe the problem:

step by step
https://github.com/firebase/quickstart-js/tree/master/messaging

Observed Results:

messaging.getToken({vapidKey: 'BNL5iJili85g3W1UMO7OZv7S1zVyF9iwTi4rPdNDUy_tpO2norwetJ_hlqEO0dBi94mhMG_qdq-Pyg4uw8t9-iY'}) // error

An error occurred while retrieving token. FirebaseError: Messaging: A problem occurred while subscribing the user to FCM: Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project. (messaging/token-subscribe-failed).

how should i do??

Same as me.

  • Chrome: Version 91.0.4472.114 (Official Build) (x86_64)
  • Os: macos catalina 10.15.3
  • Firebase SDK version: 8.6.8

curl 'https://fcmregistrations.googleapis.com/v1/projects/test-7fff6/registrations'
-H 'authority: fcmregistrations.googleapis.com'
-H 'sec-ch-ua: " Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"'
-H 'accept: application/json'
-H 'x-goog-api-key: AIzaSyBR2DCCc9zqiCeMojdNYsb_fmm1Wkme4KU'
-H 'x-goog-firebase-installations-auth: FIS eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6IjE6Mzg0MDU3NzI3MzUwOndlYjo1YWJiZDQyZDdmNWZhOTRlNDM0MjU3IiwiZXhwIjoxNjI1NzQ3NzEzLCJmaWQiOiJjbnZlLU5CdlNDQXpKZTdnYWJDSHJ5IiwicHJvamVjdE51bWJlciI6Mzg0MDU3NzI3MzUwfQ.AB2LPV8wRQIgPZt0h5HCRM4PN4R74DKXns3THn8oPuk4_Vyo44WqnvYCIQDzgLrKl35-L9U5ai9vSN7IAXYBZZi-hPDp3bgqX-TNkg'
-H 'sec-ch-ua-mobile: ?0'
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36'
-H 'content-type: application/json'
-H 'origin: https://dev.g.alicdn.com'
-H 'x-client-data: CIS2yQEIpbbJAQjBtskBCKmdygEIoKDLAQjd8ssBCI74ywEItPjLAQie+csB'
-H 'sec-fetch-site: cross-site'
-H 'sec-fetch-mode: cors'
-H 'sec-fetch-dest: empty'
-H 'referer: https://dev.g.alicdn.com/'
-H 'accept-language: zh-CN,zh;q=0.9,ja;q=0.8'
--data-raw '{"web":{"endpoint":"https://fcm.googleapis.com/fcm/send/d9x_HRJKJHo:APA91bEOqtQLGurHnKVyr8EaIqL06muPvKurbqjrGjkrep9xfj31C4b2iefdN6dZsw-a4oiRi78nCH9mDb0ypOTB4FBL-RP_8iTTWO0BQ56kJrRsbiXEJalx5DqxHdhhb2672sPt8lud","auth":"Z1Lsr2Qwk_NkVZc1sTGSAA","p256dh":"BK1PXbcZAgDWM5Vx0aWZvQ-Wf9s4Si9bybCtFKMn7lrDUSvmh2OvlgKqqsK5RQW9ySvV9KFgnvAIlbioaDbDV-4","applicationPubKey":"BN7QEPrRd6ey-mYKw8OE8hb0uxcxh0WmDq6J6U5pC0oP6qriVKVg3KhAIf6ALu_ZJ315SUT3LpeT_NCuzIEydiE"}}'
--compressed

Interesting that you both ran into this issue at the same time, are these new issues in an existing codebase?

It seems pretty unlikely that this is an issue with the quickstart-js repo. If this is happening in production I'd encourage you to report this to Firebase Support: https://firebase.google.com/support

Ah this is the same issue:
firebase/firebase-js-sdk#5081

Let's centralize the discussion over there.