GithubHelp home page GithubHelp logo

Comments (4)

malcolmdeck avatar malcolmdeck commented on June 14, 2024 1

Hey there, Malcolm from the Firebase team here!

You can link a phone credential to an existing account, but you can't do it using the #linkWithPopup() method. You can use either of:

  1. #updatePhoneNumber()
  2. #linkWithCredential()

The reason that you can't use #linkWithPopup() is that that method is specifically to launch a popup to show an OAuth login screen (for example, Google Sign-In), and then link the credential. For Phone Auth, you instead need to use the intermediary credential from the Phone Authentication flow, which you can get by calling

firebase.auth.PhoneAuthProvider.credential(confirmationResult.verificationId, code);

as mentioned in this guide.

I hope that that clears things up!
~Malcolm

from snippets-web.

samtstern avatar samtstern commented on June 14, 2024

@cp-bwg is there something you tried that is not working?

from snippets-web.

geek-at avatar geek-at commented on June 14, 2024

I have the same problem. When I'm initially logging in via Phone authentication, I can add another account (like a gmail) without a problem using snippets from https://github.com/firebase/snippets-web/blob/master/auth/link-multiple-accounts.js

But when I first log in via Email and want to link a phone number I get the error

code: "auth/invalid-oauth-provider"
message: "EmailAuthProvider is not supported for this operation. This operation only supports OAuth providers."

This is my the snipped that produces the error (while being logged in with only an email address):

var phoneProvider = new firebase.auth.PhoneAuthProvider();
firebase.auth().currentUser.linkWithPopup(phoneProvider).then(function(result) {
    // Accounts successfully linked.
    var credential = result.credential;
    var user = result.user;
    console.log(credential,user)
}).catch(function(error) {
    console.log(error)
});

from snippets-web.

geek-at avatar geek-at commented on June 14, 2024

@samtstern is this a known problem or is it by design?

from snippets-web.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.