Delegating token with Firebase after linking accounts with a Rule.

I have username/password login integration with Firebase in my web app and that is working great. I’m attempting to add ability to login with Facebook, and link accounts using this Rule:

This works and does link and merge accounts in Auth0. However, it does not seem to delegate the token with firebase correctly on the app side… in my app.js I have this for delegating the token:

lock.on("authenticated", function(authResult) {
    localStorage.setItem('id_token', authResult.idToken);
    localStorage.setItem('access_token', authResult.accessToken);

     // Set the options to retreive a firebase delegation token
        var options = {
          id_token : authResult.idToken,
          api : 'firebase',
          scope : 'openid name email',
          target: auth0ClientId

        // Make a call to the Auth0 '/delegate'
        auth0.getDelegationToken(options, function(err, result) {
          if(!err) {
            // Exchange the delegate token for a Firebase auth token
            firebase.auth().signInWithCustomToken(result.id_token).catch(function(error) {

      lock.getUserInfo(authResult.accessToken, function(error, profile) {

        if (error) {

        localStorage.setItem('profile', JSON.stringify(profile));


I think maybe the timing between the Rule and the getDelegationToken is out of order - do I have to move that piece to the rule or can I trigger it to run again once the accounts have been linked?

I am having the same issue! Anyone can help?

I was able to solve this I believe by changing:

scope : ‘openid name email’


scope : ‘openid’,

I have just tried but it didn’t work, still 2 accounts in Firebase

Oh, I think you are having a different problem than my original post. I’m still having the duplicate firebase account problem, going to work on that this week, if I find a solution I’ll post it here.

I think i found the Firebase duplicate account issue, it’s because the Rule script, it picks the new account as the primary account, which at that time does not exist in the Firebase. To solve this, it needs to pick the existing account in the Firebase as the primary account.