Comments (4)
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:
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.
@cp-bwg is there something you tried that is not working?
from snippets-web.
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.
@samtstern is this a known problem or is it by design?
from snippets-web.
Related Issues (20)
- romeo HOT 2
- Delete this HOT 2
- Now code on mobile with Dcoder
- Email verification not sent to edu account
- missing keyword `await` for the set_with_merge.js file HOT 1
- Error in v-on handler (Promise/async): "TypeError: doc is not a function" HOT 2
- import module name incorrect for firebase/database HOT 2
- Oudated link for user object properties HOT 1
- Unhandled Runtime Error TypeError: Cannot read properties of null (reading 'displayName') in next js HOT 3
- Recaptcha Verifier throws an error
- A HOT 1
- is that supposed to be test suites without expect or assert ?
- Www.contoso.com
- Missing auth_set_persistence_local.js ❓ HOT 1
- er HOT 1
- Unable to link a Custom Token SignIn with an Anonymous User
- One account should be deleted before linking two existing ones
- Update Password : getASecureRandomPassword is not defined
- Incorrect syntax, Not working properly. wrong way to console HOT 1
- It should be deleteDoc, not updateDoc HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from snippets-web.