Comments (5)
The problem happens only with Facebook -> Google.
The Google login provider will always take precedence over the Facebook one, here's an example:
Let's say my email address for Facebook and Google is the same: [email protected]
-
If I login with Firebase using my Facebook account it will register with my email address, but it won't be trusted.
-
If I then login with my Google account, the Facebook data will be overwritten with the Google one and the email address will become trusted.
-
At this step I can't login anymore with Facebook, I will need to login with Google or it won't work at all (the Facebook login doesn't return the refreshToken anymore).
In this case you will have to tell the user that they can't login with Facebook anymore and they should use Google instead.
from firebase-as3.
So allowing the user to login from multiple providers would fix this option?
from firebase-as3.
Found a hack. Not 100% sure if this is a good idea, but it works.
Basically, if you log in with Facebook after you've used Google, Firebase will return errorCodeEmailAlreadyInUse
error, so all we have to do is check if the error is of that type and just log the user in with Google.
FIRAuth.auth()?.signIn(with: FIRCredentials, completion: { (user, error) in
if let errorCode = error?._code,
let authError = FIRAuthErrorCode(rawValue: errorCode) {
switch authError {
case .errorCodeEmailAlreadyInUse:
GIDSignIn.sharedInstance().signIn()
default: self.showError(withMessage: "Couldn't sign in with Facebook")
}
}
})
from firebase-as3.
Nice find!
Tonight I will give it another shot at this issue and document my results.
from firebase-as3.
I tried the following:
I had already my account with Gmail and logged in with Facebook, the login was successful and this was the response:
{
"kind": "identitytoolkit#VerifyAssertionResponse",
"federatedId": "http://facebook.com/1127852910645790",
"providerId": "facebook.com",
"localId": "QcGrHghblIg4T2qLWP0RVJL8AQf2",
"emailVerified": false,
"email": "[email protected]",
"oauthAccessToken": "<Medium sized string>",
"oauthExpireIn": 5183999,
"firstName": "John",
"lastName": "Smith",
"fullName": "John Smith",
"displayName": "John Smith",
"idToken": "<Long String>",
"timeZone": "-6",
"photoUrl": "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/418143_223575787734578_1621690654_n.jpg?oh=25b36d4a93ebcede1245e2944b188130&oe=596B6757",
"context": "",
"verifiedProvider": [
"google.com"
],
"needConfirmation": true,
"rawUserInfo": "{my Facebook profile information as sent from the Graph API}"
}
The important things to notice are:
- There's not a refreshToken in the response, which is the key for doing anything with auth in Firebase.
- emailVerified is set to false. This value is set to true when I log in with Google.
- needConfirmation parameter which only appears when I try the previous sequence of actions.
My guess is that the Swift API already knows about this and gives you this particular error. In my case I will need to manually detect if the refreshToken exists and if not, redirect the user to the Google Auth.
from firebase-as3.
Related Issues (20)
- Google Policy Issue HOT 11
- requestType strings have changed HOT 5
- Getting Google And Facebook tokens HOT 1
- error request uploading file with progress HOT 1
- A couple of requests HOT 8
- Firebase Phone Auth HOT 3
- Image Upload in FlashPlayer HOT 7
- can't connect with facebook login
- Delete is not Deleting HOT 2
- Messaging? HOT 1
- Sort HOT 1
- Delete à folder HOT 3
- Cloud Firestore HOT 4
- Indicator for Realtime?
- Typo in "Email and Password" section HOT 1
- RealTime - Error #1132: Invalid JSON parse input HOT 2
- OSX Mojave can not login Error 400
- Images uploaded to Firebase Storage don't load in Flex
- Relogging in? HOT 3
- upload files using File.upload? HOT 2
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 firebase-as3.