firebase-authentication

Authenticating phone number without sending SMS in Firebase for Android

不羁的心 提交于 2020-05-24 05:06:33
问题 I want to use Firebase phone number authentication. My code is this: LoginActivity.kt import android.os.Bundle import android.util.Log import android.view.View import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import com.google.android.gms.tasks.Task import com.google.firebase.FirebaseException import com.google.firebase.auth.AuthResult import com.google.firebase.auth.FirebaseAuth import com.google.firebase.auth.PhoneAuthCredential import com.google.firebase.auth

Google Sign-in removes existing user data

烈酒焚心 提交于 2020-05-23 21:13:09
问题 I'm building an Android app with Firebase Authentication and Cloud Firestore. The app has multiple Auth providers; a user can sign in either using his registered email and password or using Google or Facebook. So here's the problem: When a user first logs in with his own registered email and password, he stores his details in a document in Firestore. Now, if the same user logs off and signs in using Google (linked to the same email address), the login is successful, but the Firestore doc is

How to get Firebase user id from FCM token? (in admin code on server)

ε祈祈猫儿з 提交于 2020-05-23 10:49:29
问题 My signed-in Android clients register their tokens with my server. The problem is I am not sure whether the token sent by a particular client genuinely belongs to that client user id. A bad client could register valid tokens of other users. Given an FCM token and a user id, how can my admin code on the server verify that the token indeed belongs to the (authenticated) user id? 回答1: On a Firebase level there is no connection between a Authentication UID, and a Cloud Messaging Instance ID token

How to prevent access to Firebase Realtime Database from browser console?

三世轮回 提交于 2020-05-23 07:18:51
问题 I have this JavaScript code where users sign in to my app using their google account. //firebase db congifurations const config = { apiKey: "my_api_key", authDomain: "my-app.firebaseapp.com", projectId: "my-app", databaseURL: "https://my-app.firebaseio.com", }; //signin callback implemented using - https://developers.google.com/identity/sign-in/web/sign-in function onSignIn(googleUser) { var profile = googleUser.getBasicProfile(); let fullName = profile.getName().split(" "); let userName =

How can I validate user is already signed up?

ⅰ亾dé卋堺 提交于 2020-05-17 08:28:27
问题 How can I validate user is already signed up? private void firebaseAuthWithGoogle(final GoogleSignInAccount acct, final GoogleSignInResult result) { AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mAuth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { //HOW CAN I validate user is already signup or not if

How to use Firebase Authentication with Okta?

寵の児 提交于 2020-05-17 06:57:28
问题 I am currently using Firebase Authentication in my app using the built-in OIDC providers (Google, Facebook etc.). Is it possible to use Okta as an additional OIDC provider with minimal modifications to my app, meaning Okta should behave just like any other built-in provider? Firebase Auth apis, such as firebase.auth().currentUser and firebase.auth().onAuthStateChanged() should still work. The doc page for Custom Authentication talks about getting a custom token from an auth server, but does

Firestore security rules: get() use in hasAny() list method

狂风中的少年 提交于 2020-05-16 22:39:09
问题 I was wondering if this security rule would be possible: function productForUser() { return resource.data.products.hasAny(get(/databases/$(database)/documents/Users/$(request.auth.uid)).data.products); } When I try to test it in the testing plaground on the Firebase website, it is sucessful. However, when I try to run it with Javascript, with this query, I get the read denied, with "missing or insufficient permissions": query.where("products", "array-contains", productId); I can confirm that

Firebase: reauthenticate with phoneNumber

人盡茶涼 提交于 2020-05-16 08:53:07
问题 I know that I can reauthenticate with email like this. var user = firebase.auth().currentUser; var credentials = firebase.auth.EmailAuthProvider.credential( user.email, 'yourpassword' ); user.reauthenticateWithCredential(credentials); But how can I reauthenticate if I use phoneNumber as my sign in method? 回答1: It is very similar to how you sign in with phone number. You can do it in 2 ways: Using reauthenticateWithPhoneNumber : const recaptchaVerifier = new firebase.auth.RecaptchaVerifier(

How to logout user from firebase database?

六眼飞鱼酱① 提交于 2020-05-16 03:32:33
问题 I'm using firebase database using firebaseUser authorisation. I successfully logout user from app, but when I logout user the app is crashed due to firebase database reference. I got logcat message showing that This client does not have permission to perform this operation. How can I logout user from firebase database? 回答1: You don't logout from the "database" as such, but logout from Firebase with FirebaseAuth.getInstance().signOut() . After that, the user can't access parts of the database

iOS/Swift/Firebase Authentication: Help Needed on Accessing “isNewUser”

拟墨画扇 提交于 2020-05-16 03:19:09
问题 In my iOS/Swift/Firebase app, I am trying to access the "isNewUser" parameter after a user successfully signs in via email/password so that I can pop a window to compel them to reset their password from the temporary one initially assigned upon user creation. Any insights would be appreciated. Thanks. 回答1: The .isNewUser method is available from the FirebaseAuth AdditionalUserInfo class. Here is the link. In order to utilize this code, please see a demo sign in function I wrote below. Auth