Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Auth: provide custom nonce on # #8665

Open
jarvandev opened this issue Dec 4, 2024 · 2 comments
Open

Auth: provide custom nonce on # #8665

jarvandev opened this issue Dec 4, 2024 · 2 comments

Comments

@jarvandev
Copy link

jarvandev commented Dec 4, 2024

Operating System

macos

Environment (if applicable)

chrome 131.0.6778.86

Firebase SDK Version

11.0.2

Firebase SDK Product(s)

Auth

Project Tooling

react app with vite

Detailed Problem Description

When using the Twitter provider for login, we receive a JWT token. However, the payload of this JWT token does not include a nonce by default. We would like the JWT token issued by Firebase to include a custom nonce that we provide. Currently, we cannot find a way to supply this nonce. Is there any method to achieve this?

Steps and code to reproduce issue

We want to provide our custom nonce in signInWithTwitter function.

import { initializeApp } from 'firebase/app';
import { getAuth, TwitterAuthProvider, signInWithPopup } from 'firebase/auth';

const firebaseConfig = {...firebaseConfig};

const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const twitterProvider = new TwitterAuthProvider();

export const signInWithTwitter = () => {
 // we want to provide custom nonce here
  signInWithPopup(auth, twitterProvider)
    .then((result) => {
      const credential = TwitterAuthProvider.credentialFromResult(result);
      console.log('credential', credential);

      const token = credential?.accessToken;
      const secret = credential?.secret;
      // ...

      // The signed-in user info.
      const user = result.user;

      console.log('token', token);
      console.log('secret', secret);
      console.log('user', user);
      console.log('credential', credential);
      })
    .catch((error) => {
      const errorCode = error.code;
      const errorMessage = error.message;
      // The email of the user's account used.
      const email = error.customData.email;
      // The AuthCredential type that was used.
      const credential = TwitterAuthProvider.credentialFromError(error);
      console.log(errorCode, errorMessage, email, credential);
    });
};
@jarvandev jarvandev added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Dec 4, 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 and removed needs-triage new A new issue that hasn't be categoirzed as question, bug or feature request labels Dec 4, 2024
@DellaBitta
Copy link
Contributor

Hi @jarvandev,

I've marked this as a feature request here but I recommend that you also open a Firebase Support Ticket. This feature would require changes to the Firebase Service which is beyond the domain of those of us who support Firebase JS SDK. Instead, the Firebase Support team would be your best path forward for this issue. Thanks!

@DellaBitta DellaBitta changed the title provide custom nonce Auth: provide custom nonce on # Dec 16, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

4 participants