Create a Firebase user with password and provider - android

I managed to successfully create users with a password using the Python Admin SDK, but I want to add Google suport, too. I understand I can have a link to sign in with Google in the app, but then the password is overwritten. I could have an option to merge the password with a Google account using linkWithCredential, but then the user still has to use the password at least once.
Using the Admin SDK, I first created a user normally then used the generated UID to re-import the user with Google.com set as a provider. The console shows that the user is able to sign in with password and google.com, but the password keeps getting rejected with ERROR_WRONG_PASSWORD (but password is still shown as an option when using fetchSignInMethodsForEmail).
How can I create a user that can sign in with both their password and Google?

Related

Firebase Android Studio Reset Password : Ask user to enter new password twice from sendpasswordresetemail

I am developing an app on Android Studio using Firebase. There is an option for users that has forgotten password. They will be prompted to enter their email and using Firebase send sendPasswordResetEmail(email), where an email to reset their password will be sent. However, when clicking the link user is prompted to only enter their new password ONCE. For security purposes, is there a way to ask user to enter their new password TWICE instead of just ONCE?
The page when clicking the link in sendPasswordResetEmail
I've tried using Deep Link, Android App Link, Action Code Settings, or Sign-In Email Authentication Link but it all seems too complex and doesn't exactly match what I want.
All I want is for when users click forget password, they need to enter the new password TWICE instead of just ONCE, and obviously for some authentication step to confirm that it is the right user that has forgotten their password and not some random person.

I want to add user manually into Firebase and try to login into my app but getting error like "PLEASE VERIFY YOUR EMAIL TO LOGIN"

I have added the EMAIL VERIFICATION PART in my project.
So every user need to verify their email before login.
But I want to add some user manually in Firebase, and I did that also into my project and I successfully added that.
BUT main problems is that when I try to LOGIN using that email I am having error message like "Please verify your email...".
But as I told you earlier I added user manually in Firebase, so I didn't receive any verification email into that perticular account.
So is there any way to login using manually added users into my app?
Firebase Authentication doesn't check anywhere whether the user has verified their email address. So if your app shows a message to that effect, it's either your application code, or a library that you use, that is show the message.
Normally a user's email address is only changed to verified if they follow the flow outlined in sending a user a verification email. You can do this from your application in the same place where it now detects that the user is not verified.
Alternatively, you can mark the user as verified using the Admin SDK, after adding them in the console. For an example of how to do this, see update a user profile in the documentation. Keep in mind: the Admin SDKs can only be run in trusted environments, such as your development machine, a server you control, or Cloud Functions.

Firebase reset password issue for users with social media authentication

I am trying to reset password for Firebase in iOS for a user who has email authentication as well as Facebook and Twitter authentication in Firebase.
The password is reset successfully and the user ID is the same, but the user's Facebook and Twitter authentication is removed (see below). How do I reset password in Firebase without removing social media authentication?
User authentication with social media linking before password reset
User authentication with social media unlinked after password reset
This issue also occur on Android
The following reply from a Googler seems to indicate that the unlinking is an intended consequence of the password reset to allow the user to recover their account in the case it was hijacked and modified by another user:
https://stackoverflow.com/a/44694017/1171539
First I would check the method they used to sign in:
You can lookup the providers linked to an account using: fetchProvidersForEmail
To reset the password, use: sendPasswordResetWithEmail
There are also instructions on how to send the password reset and redirect back to app: https://firebase.google.com/docs/auth/ios/passing-state-in-email-actions
see Firebase forgot password- how to identify whether user signed in with email or facebook?
Once you know the sign in method, if the method is email/password, you can call to specifically reset the password with email only. If it's social media then you can just not reset it, or ask the user to unlink the account, reset the password of the account, and relink the account if you're really determined.
Have you tried that?

Using com.google.android.gms.auth to pass user credentials to sign in google account

I am trying to build an app to use com.google.android.gms.auth api for google sign.
I don't want to prompt to user for entering username and password. I want to pass the credentials using the code and sign in user directly.
Can anyone suggest a way to use this?

Can't save IdentityProviders.GOOGLE credentials with SmartLock

I'm logging my users into our app using Google+. The actual G+ signing in happens on the server though. I get back some user data such as email and name. I'm using this to store the users credentials as a google account.
The issue arises when I try to save it. In the callback to save the creds in "Auth.CredentialsApi.save" it returns no resolution and nothing ends up happening. If I remove the Google IdentityProvider from the creds then it saves without a password.
Does anyone know why a resolution is not found when the IndentityProvider is set?
In Play Services 8+, no resolution (confirmation UI) is required to save a Google Sign-In to the user's Google Account using the Smart Lock API (i.e., the credential's type is set to IdentityProviders.GOOGLE and the email address matches one signed in on the device, and the user has not disabled saving in settings). Note that you cannot set both an account type and password on a credential object when saving with the API -- if a user has a password simply store that for authentication purposes.
An API call with a credential of this type should save automatically and be available immediately, so just check that this credential is available when making a Auth.CredentialsApi.request() using a CredentialRequest built with .setAccountTypes(IdentityProviders.GOOGLE) and that the saved credential is shown on passwords.google.com and has "with Google" in place of a password.
When retrieving this credential, you can use it to know that you've got a user with an existing account and they signed in with Google previously. You then can customize the auth UI for this returning user, or simply trigger a Google Sign-In flow for the user automatically and give them a returning user experience when the app starts using the Auth.GoogleSignInApi.silentSignIn() method in the latest version of the Google Sign-In library. Here's a full code example.

Categories

Resources