How to add email&password login method to existing account that was created with a third party provider such as google/facebook on my firebase project - flutter

I just implemented Google OAuth social sign in to my firebase project today, and it works.
I have tested it with a new google account (with an email address that wasn't used yet in my firebase project), this worked.
I have tested it signing in with my usual google account, which uses the same email address as one of the accounts in my firebase project (with email&password login). In Firebase console I could see the Google logo got added next to the email icon on my user, this is exactly what I expected.
Now my problem is, I don't know how to add email & password login to an existing account, that was created with a third party provider.
To test this I have first created an account on my firebase project using google.
I have tried to sign in by using the same email address associated to that google account, which obviously wouldn't work as there is no password set.
I have tried to sign up (register) by using the email address, which would throw a FirebaseAuthException with the error code email-already-in-use.
And I have recognized a flaw in this logic^^: Let's say Bob creates an account on my firebase app with Google. Then just about anybody could use his email address and a new password to register, and therefore login to his account. A correct solution is to only allow the user to add a password while signed in or by requiring authentication.
I couldn't find any relevant method on FirebaseAuth.instance that could be the answer to my question.
I have noticed that many apps with social logins provide the Apple login ONLY for their iOS app.
If I do the same, the worst case scenario I can think of which is caused by this problem is:
Someone with an iPhone downloads my app and creates an account with Apple login.
Then that person switches to Android. Now that person can't use Apple login, and also can't log in to my app with their email address.
So for now, I have to include Apple login for my Android app too, and I don't see a reason why I should not do that. But I still want to find a solution to my question, as that could be an annoyance to users of my app.
See this video from the official Firebase YouTube account.
I want to clarify, my questions is different from this, so don't redirect me to it.

I have just found the answer to my question and implemented the funcitonality in my own project.
This webpage from the official firebase docs explains exactly how to do that.

Related

Link multiple accounts iOS app - Firebase/Facebook Login & XCode/Swift 5

So I'm building this app for a client (It's a basic scheduling app like HootSuite but simpler) and he wants the ability to add multiple Facebook accounts with an IAP (aka In-App Purchase) after said IAP is purchased. The IAP is all done and works great but I cannot figure out how to link multiple Facebook accounts. I tried to use the same login method that a previous developer used (It's an ongoing freelance project and 2 other devs worked on it before I joined) to no avail since the login process stops once the app realizes that the user has already signed in...
So I guess that my question is this: Is there a way to link multiple Facebook accounts at once in a single iOS app? If so, how exactly? Forget the IAPs if that's too confusing, everything is fine there anyways. The goal is to be as seamless as possible, so ideally there would be no need for the user to log out and log back into the other account (Something I've seen a lot in other Questions/Answers).
I don't think I am authorized to show the code to you guys (that would also require sharing the entire project, it's a real spider-web!), but could someone please lead me in the right direction?
Please let me know if you have any questions!
Thank you in advance.
Notes:
Just like the title says, we use Firebase for our storage, Cloud Firestore for our database and Facebook login (through Firebase) for login since the purpose of the app is to schedule posts on IG.
I use a basic variable called "activeUsers" to track the number of accounts "linked" to the app so we can know whether or not to show the "PurchaseModel" and, obviously, receipt verification and all that for IAPs. Thought it could be useful!
3. When the app starts, you are prompted to link a Facebook account to enable the scheduler. THIS WORKS GREAT! What I am trying to achieve is to add other accounts AFTER the first one has been "enabled"/logged into.
It's not possible to link multiple accounts from the same provider to a single Firebase Auth account.
You can only link multiple accounts of different types (Facebook, Google, GitHub, etc) to a single Firebase account as described in the documentation.

Google assistant account linking with facebook

I'm trying to make a chatbot with Dialogflow for Google Home. It requires the user to input a URL. Now it will definitely be a long and complicated URL which I can't recreate and I can't have the user speak into the google home.
The idea I had was that the user would input the URL on an agent on messenger. I store this on a Firebase database and then access it with a second agent.
Now the issue I have is authentication, I was hoping to use account linking on my google action with facebook. But I can't login to Facebook with google home. Or if I can, I can't find any documentation specific to that case. Facebook doesn't provide the necessary client ID and secret(as far as I can see).
I managed amazon and Gmail account linking with Alexa and an Amazon Echo. In those cases, you would have to login to google or amazon on the Alexa app or webpage. Then this will be integrated with your Echo and the skill will become usable.
Anyone have an idea of how I can make the link happen, if not then anyone have an idea as to how I can solve the overall problem?
This question has been left unanswered on other forums, but I was hoping to either get it solved or find an alternative.
There are three approaches to solving your overall problem - getting the URL manually entered and available to your Action. Two of them tackle it the way you've suggested - involving authenticating to Facebook and tying that to the Assistant account somehow. One solves it entirely inside the Assistant.
Account linking to the Facebook account
You've tagged firebase-authentication, so I'm going to assume that you're using it to do the auth and you've enabled Facebook login through it. This means your user has a "Firebase Account", but they log into that account using Facebook.
I will assume you have a way to get the URL from messenger once they're logged in.
The trick in this case is to setup Account Linking between their Firebase account and their Assistant account. This is done by setting up an OAuth2 server that has access to the Firebase accounts and will create authorization and refresh tokens that are given to the Assistant.
In the Action, you'll send the user to the Sign In helper, which will redirect them to your login page and send back a one-time auth code to the Assistant. The assistant will then use your OAuth2 server to exchange this code for auth and refresh tokens. Periodically it will use the refresh token to get new auth tokens.
When the user returns to the conversation through the Assistant, you'll be handed an auth token and you can use this to lookup the user. Since you also know their Facebook account, you can get the URL via however you planned to do so.
There are drawbacks to this method - it is very complicated, and setting up your own OAuth2 server is not for the faint of heart. You may be able to use something like Auth0 instead of Firebase Authentication to accomplish the same thing, but then you don't have the ease of access to the Firebase database.
Account linking to both Facebook and Google
In your Firebase account, however, you don't need to limit them to just logging into Facebook. You can have them use Firebase to record both the Facebook and Google accounts that they're using. This would "link" the two accounts together in your system.
With this, you don't need to setup an OAuth2 server. Instead, you can have the Assistant use Google Sign In for authentication. If the Google Cloud Project that Firebase is using and the Assistant are using are the same project, then once the user has logged in to your project's web page with their Google account, you'll get an identity token on the Assistant which will contain their Google ID. You can use this to match up with their Firebase account and get the Facebook ID and proceed from there.
But this is still a lot of work and kinda messy, jumping between systems.
Using just the Google Assistant (and maybe a web page)
If you're willing to make some assumptions about the devices your users are using, then you may be able to do it all just using the Assistant. The Assistant doesn't just run on the Google Home and other smart speakers, it also works on most current Android and iOS devices.
So you can detect if they have such a device available and, if they do and they're not currently on it, direct them to switch to that device when you need the URL.
If they don't have such a device available (perhaps because their version of Android is older), and you think this may be a common scenario, you may need to make another entry source available. This could be one of the solutions above, or you may want to just have a simple web page (done via Firebase Hosting and Firebase Functions, perhaps) where they log in using their Google account (so you get their ID) and you let them enter the URL. If you just need a URL - going through Dialogflow may be more complexity than you need.

How to create a Facebook App?

Preamble:
I'm not a Facebook user, I never had any Facebook account, so I'm not familiar at all with the Facebook website.
I need to create a Facebook App
Today I need to implement "Facebook Connect" (authentication) for the website of a client. I'm using an existing extension which requires me to enter my App ID and Secret key, which can be obtained by creating a Facebook App.
1: Where to get started?
According to both the Facebook Documentation and the extension I'm using, a Facebook App can be created by going to the following URL: https://developers.facebook.com/apps/
2: Account required
When I go to that URL I am asked to login. Very well, so I go ahead and create my very first Facebook Account. On the registration form it says that if the account is created for a business then I don't need to enter my personal name. This account is not for me but for my client's website, and my client being a business, I go on and open a business account.
3: Account verification
To complete, I am required to verify my email address, which I do successfully. After that, it asked me to verify my personal phone number, which I do successfully.
4: Account created & verified: still can't access the App Creation page
Now, I finally have a Facebook Business Account. I go again to that same URL to create a Facebook App: https://developers.facebook.com/apps/. However, I still can't access the page as according to the Facebook Documentation it seems that I need to convert my account to a "Developer Account".
5: Developer Account required
Very well, I follow the process of converting my account to a Developer Account, provide all kind of information about me and the company hiring me, and finally, I now have a Developer Account, yeey!!
6: Second attempt
Ok, now it should certainly work and I will FINALLY be able to create this dawn app to start implementing Facebook Connect on my client's website!
Double checking that the URL is the correct one from the documentation of the plugin, and also from the Facebook Documentation itself, I go ahead and refresh this page: https://developers.facebook.com/apps/
7: Still fail: now getting redirected to Facebook Advertising
But now, when loading the above URL, I am automatically redirected to the following page: https://www.facebook.com/advertising
I have tried to log-out, erase all my cookies, login again, but nothing will do, when I go to https://developers.facebook.com/apps/ I am always redirected to https://www.facebook.com/advertising which is about creating ads but what I need is to create an app!
8: Personal Account required
I searched all over the place for an explanation or maybe for a newer URL, but no luck. I finally found on StackOverflow (Can't access Facebook Developers App!!?! Redirected to my page repeatedly) that I can't create a Facebook App with a Business Account, and that I need a Personal Account instead.
9: Personal Account creation
Very well, I go ahead and create my very first personal account on Facebook.
10: Can't create a personal account, email and phone already used!
Oops, it says that my email was already used for another account. Hmmm OK so I go ahead and create a new email address especially, and then try to register a personal account again. Now it is asking to verify my phone number, which I do, but unfortunately it says that my phone number was already used to verify another account earlier today!
Dawn, I'm really starting to feel exhausted by Facebook. Let's think about a solution. I have only one phone number, and I wouldn't use the phone of a friend as they all have Facebook and all probably verified their own accounts using their phones.
11: Deleting my Business Account created earlier
Solution founds! I will delete my business account, so my real email and my phone number will be available again! Yeey!!!
12: Facebook won't delete my account today
A few minutes later, I understand that my Facebook Account cannot be deleted today. I can deactivate it. But this won't free my email nor my phone number. After some research on the web I found a hidden form that allows to really delete my account. I go ahead through the deletion process, enter my password about 10 times, and fill 10 really hard CAPTCHAS, and finally my account is deleted! Oh wait... it says it won't be deleted before 2 weeks!!!
13: Final attempt: fail again
Anyway, I still try to use my phone number again to create a personal account, but still no luck, Facebook won't let me use my own phone number to activate my account.
What are my options?
Have you looked at all into dummy phone numbers, such as with Google voice (free) or with Skype (nominal fee)? Some sites, such as Craigslist, can sniff those numbers out and still not allow them to be used for verifying, but others can't tell the difference. Could be useful.
Depending on how big your client's budget is, maybe grab a throwaway prepaid phone from the store and use it. Just a few thoughts on how to avoid the phone issue. Everything else seems straightforward after that.
Building an app on Facebook gives you the opportunity to deeply integrate into the core Facebook experience. Your app can integrate with many aspects of Facebook.com, including the News Feed and Notifications. All of the core Facebook Platform technologies, such as Social Plugins, the Graph API and Platform Dialogs are available to Apps on Facebook.
In this document we will explain the following concepts:
Canvas Page: The Page in which your app is loaded.
Social Channels: The key channels that help you grow your user base and re-engage existing users.
Analytics: Accessing analytics for your application.
If you wish to start building an App on Facebook now, please refer to our getting started tutorial. If you want to build an app to add to the tab of a Facebook Page then you should refer to Page Tabs.
Visit this site
https://developers.facebook.com/docs/guides/canvas/

Facebook Registration and Login Apps, Need Guidance

I have used Face book Apps for register and login for my website (in PHP). Problem is very simple for you all experts.
When I try to login via FaceBook using my email id which I am using for Facebook developer login then I succeed but if I give any other email ID I can't able to login.
Ex.
x123#yahoo.com is id which I'm using for Facebook Developer Account
a123#gmail.com is normal Facebook user account.
Now if use x123#yahoo.com for login in my website, I am successful and redirected to Profile Page)
But if I use a123#gmail.com for login in my website I FAIL and I come back on same page from where I tried to login
Any guidance will help me to move forward I'm stuck here
By the reading of your problem I think you have your app on Sandbox mode. If you want to test on other profiles, you should consider creating Test Users.
Depending of your purposes, you may create another app just to make your tests (and therefore need not to be on sandbox mode).

creating facebook application

i have this problem..
I created account to develop facebook api for my apps..
I registered and created account and vertified with email and phone.
But when i try to create new app, i get this error:
You've been blocked from creating apps because we haven't been able to verify your account. You need to use your real name to maintain an account on Facebook
I dont get it, what do i have to do, to get my account vertified and working? I need this account only for development and i dont want to use account, cos other developers can see my password.
and when i try to ask this question anyware on facebook forums i get this message, so i dont know what to do:
This message contains blocked content that has previously been flagged as abusive or spammy
Btw, i added apps on my real facebook account, but i dont remember having any problems..
If i not understand wrongly, did you mean that you are creating another facebook account for your development purpose? actually you can use your own account to create the facebook application. After that, you can grant access to others developer from the app. They can have the access to edit your application configuration too.
Regards,
Woolei - Facebook Consultant at www.woolei.com