Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

[iOS] Unable to login using Facebook authentication #60

Closed
NordlingDev opened this issue Jun 20, 2016 · 10 comments
Closed

[iOS] Unable to login using Facebook authentication #60

NordlingDev opened this issue Jun 20, 2016 · 10 comments

Comments

@NordlingDev
Copy link

Using the latest plugin version. The login procedure will redirect me to the Facebook login page in Safari. After I sign in and accept, it redirects me to a blank page. I can only tap on "Done" in the upper left corner and a popup will say "login cancelled".

I have added the necessary lines in info.plist as Facebook stated when creating the app. Firebase config has also Facebook auth enabled with the correct API key and such.

@EddyVerbruggen
Copy link
Owner

Can you try adding this bit to app.js?

@NordlingDev
Copy link
Author

NordlingDev commented Jun 21, 2016

@EddyVerbruggen - That did work. However, the e-mail never gets recorded:

{
  "uid": "84gfhYMCQ5iVasdCH22A9LE0fndfg14",
  "profileImageURL": {},
  "email": null,
  "emailVerified": false,
  ...
}

image

@EddyVerbruggen
Copy link
Owner

I'm not sure that's expected anyway.. what does the Firebase documentation say?

@NordlingDev
Copy link
Author

NordlingDev commented Jun 21, 2016

@EddyVerbruggen - According to this post of yours, you got the email attached? I googled a little and found this. It says (although from the Firebase web API) that this needs to be included in the auth process:

auth.login('facebook', {
  rememberMe: true,
  scope: 'email,user_likes'
});

Specifically referring to the scope property there. Could that be it?

The Facebook login page should basically say this:

image

Taken from this video tutorial.

@EddyVerbruggen
Copy link
Owner

Email is already in the request and that screenshot has an email address because it was added by the 'login by email' type which was merged with the Facebook login (see the envelope above the Facebook logo).

So perhaps Firebase doesn't store the email in the console, but do you also not see the emailaddress in the login callback of the Facebook login? (not sure it should, I don't have access to my test app currently)

@NordlingDev
Copy link
Author

NordlingDev commented Jun 21, 2016

@EddyVerbruggen

Interesting... Well, as stated in a previous post, this is the callback from Facebook login:

{
  "uid": "84gfhYMCQ5iVasdCH22A9LE0fndfg14",
  "profileImageURL": {},
  "email": null,
  "emailVerified": false,
  "name": [hidden],
  "refreshToken": [long token]
}

Email is null. The rest seem to work (uid, profileImageURL, emailVerified, name, refreshToken).

The Facebook login does ask for the public profile and e-mail address (screenshot in Swedish), but the callback returns email: null:

image

As for your email adress being merged from previous email/password account. This is my result of it:

image

My Facebook uses the same e-mail address as the other one marked in red. Firebase created a new account because the e-mail was, for some reason, never received.

@NordlingDev
Copy link
Author

NordlingDev commented Jun 21, 2016

I found the issue and it seems to be a problem with Firebase itself. I had to check "One account per email address" in the Firebase Sign-in Method page. That way the email property will get the e-mail address.

Though I still think it is weird that you managed to combined the accounts together 🤔

@EddyVerbruggen
Copy link
Owner

I had that option checked from the get go. This particular user was already registered via email and later logged on via Facebook with the same email address. Then this line of code kicked in and linked the two.

@NordlingDev
Copy link
Author

NordlingDev commented Jun 21, 2016

@EddyVerbruggen Ah, I see! However, I got the alert/error "email already in use" (or something like that) if I already had an account with the same email address (pretty sure that's what the option is for - to prevent double accounts).

This solved my issue though. So thank you for your help!

@EddyVerbruggen
Copy link
Owner

If you feel this needs to be documented in the readme, or is useful for others to know, please send a PR for the readme.

Happy coding!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants