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

Request is missing required authention credential.Expected OAuth 2 access token cookie or other valid authentication credential. #8513

Open
amitromi9470 opened this issue Sep 23, 2024 · 3 comments

Comments

@amitromi9470
Copy link

Operating System

Ubuntu 22.04.4

Environment (if applicable)

Chrome Version 126.0.6478.182, react: 17.0.1

Firebase SDK Version

firebase: 9.9.4

Firebase SDK Product(s)

Auth

Project Tooling

React, Javascript.

Detailed Problem Description

I am trying to register FCM token for 200 users,But out of 200 users for some users its failing to register token with 401 error.This is the error i am getting
{
"error":{
"code":401,
"message":"Request is missing required authention credential.Expected OAuth 2 access token cookie or other valid authentication credential. see https://developers.google.com/identity/sign-in/web/devconsole project.",
"status": UNAUTHORISED
}
}

Steps and code to reproduce issue

const firebaseApp = initializeApp(firebaseConfig);

export const messaging = getMessaging(firebaseApp);
let swRegistration;

const requestForToken = async (registerFCMToken) => {
try {
swRegistration = await navigator.serviceWorker.register(${process.env.PUBLIC_URL}/firebase-messaging-sw.js);
messaging.swRegistration = swRegistration;

const currentToken = await getToken(messaging, {
  serviceWorkerRegistration: swRegistration,
  vapidKey: 'BJAig9HybaAM035dc-e4TQp0Aa0B4TEWMSiBLy14qddxnNlxRNhaaVMXIlDTI11Q-Mil_O4He4GT6hCco2im4uU'
});
return currentToken;

} catch (err) {
console.log('An error occurred while retrieving token. ', err);
throw err;
}
};

@amitromi9470 amitromi9470 added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Sep 23, 2024
@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@jbalidiong jbalidiong added api: auth needs-attention api: messaging and removed needs-triage new A new issue that hasn't be categoirzed as question, bug or feature request api: auth labels Sep 24, 2024
@amitromi9470
Copy link
Author

fcMimage

@amitromi9470
Copy link
Author

I saw same issue has been raised 3 years back but didn't see any solution for that, can we get more clarity on this issue as in the comment of this issue https://github.com/firebase/firebase-js-sdk/issues/5081 its mentioned that its a backend issue and resolved without doing any changes in js sdk.

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

No branches or pull requests

3 participants