Invisible recaptcha in Expo SDK 37 - javascript

const phoneProvider = new firebase.auth.PhoneAuthProvider();
const verificationId = await phoneProvider.verifyPhoneNumber(
phoneNumber,
recaptchaVerifier.current
);
setVerificationId(verificationId);
Can we use without recaptchaVerifier.current

No, recaptcha will always be required if you want to use the Firebase Phone Auth.
As it says in the documentation :
Firebase phone authentication is not possible out of the box using the Firebase JS SDK. This because an Application Verifier object (reCAPTCHA) is needed as an additional security measure to verify that the user is real and not a bot.
https://docs.expo.io/versions/latest/sdk/firebase-recaptcha/

Related

What is the VS2022 eqivalent to "Azure Identity Plugin for Visual Studio Code Authentication"?

im trying to authenticate towards Azure using my local user in VisualStudio2022 in my local development environment using the following:
const { DefaultAzureCredential } = require("#azure/identity");
const credential = new DefaultAzureCredential();
but nothing is found, and I'm signed in in VS2022.
Should credentials be found automatically, or do i need to spesify that it is the VS2022 credentials i want to use?
Does https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity-vscode/README.md work only for VS-Code, and not vs2022?
Edit 1: Elaboration: As i understand it, "credentials" can be from "EnvironmentCredentials", "DefaultManagedIdentityCredentials", "AzureCLI" or "AzurePowerSHell".
Beeing logged into azure with corret subscription in VS2022, i expected my credentials to be in one of these to contain my credentials.
Btw: i get a "DefaultAzureCredential => failed to retrieve a token from the included credentials. To troubleshoot, visit"
What is the "included credentials" ?
Edit 2: I can get a token using Azure CLI as descibed here: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/TROUBLESHOOTING.md#verify-the-azure-cli-can-obtain-tokens
This was solved using the azure sdk require("#azure/identity");
And i guess its fetching credentials though AzureCLI , event though its not visible when instantiating the credentials, which i was expecting. But its all undefined as can be seen in picture below.
Then, just trying to get the secret from keyVault it worked, although i'm not 100% sure how its working.
const client = new SecretClient(url, credential);
await client.getSecret(secretName);

Is there a way I can add users with phone number to firebase admin sdk

I am building a react app with firebase backend.
I would like an administrator to be able to add users to the app using the Firebase admin sdk.
Usually I would do that using a cloud function like this:
return admin.auth().createUser({
email: data.email,
password: data.password,
displayName: data.name,
disabled: false
})
How can I achieve the same using just the phone number and not the email and or password?
Please help.
Thanks.
I think phone auth support is not available in Firebase Admin SDK directly.It does not provide end user authentication methods in the Admin SDK.
As this document mentioned by frank in the above comment,if you create with just phone number by excluding email and password fields.you will get a warning, you are creating user with email without giving email and password fields that are filled with blank fields.But this should not done as per best practices I have tried in the past and it worked but with a warning
phone auth support available in Firebase client SDKs. The FirebaseUser object you get when you complete the phone number sign in contains the unique ID of the user. It also takes care of creating the user account in the Firebase project:
From this document
"After a user signs in for the first time, a new user account is
created and linked to the credentials—that is, the username and
password, phone number, or auth provider information—the user signed
in with. This new account is stored as part of your Firebase project,
and can be used to identify a user across every app in your project,
regardless of how the user signs in."

Why Firebase (onAuthStateChanged) does not see a Google signup user (with signInWithCredential)?

So I followed this tutorial on how to sign in a user with rnfirebase and google signup. And it works fine. Here is the code:
const googleSignUp = async () => {
// Get the users ID token
const { idToken } = await GoogleSignin.signIn();
// Create a Google credential with the token
const googleCredential = auth.GoogleAuthProvider.credential(idToken);
// Sign-in the user with the credential
const user = auth().signInWithCredential(googleCredential);
return { idToken, user };
};
(Let me note here, that the app has already a sign in with email and password way, with Firebase).
Then I realized that the user cannot change his name, email or delete his account.
Looking deeper, I found out that the onAuthStateChanged(firebase.auth, async (user) => ... returns null for the user.
I've seen in some older answers that if you use Google sign up, you need to sign up the user with signInWithCredential, which I use, so this in not the issue.
Could it be a problem that for email/password sign in, I use code from Firebase web and not from rnfirebase? Although I already had a combination of those, using the push notifications from rnfirebase.
Can someone explain why I get this behavior, and how to fix it?
Thanks!
If I understand correctly, you use both the react-native-firebase library (which wraps the native iOS and Android SDKs) and the JavaScript Web SDK for Firebase in your app.
If that is the case, both indeed have a separate sign-in state, and signing into one won't fire onAuthStateChanged listeners on the other.
You'll have to pick one SDK to authenticate with Firebase, and then use that for both providers.

Firebase authentication using google/facebook with custom nodejs server

I am trying to integrate firebase authentication with my custom nodejs server. The email/password strategy is pretty straightforward as the admin sdk supports all the operations needed. However in the case of providers, the documentation instructs us to Handle the sign-in flow manually
and get some token from either google or facebook and then send it to our nodejs server.
So when the token arrives to our nodejs server the documentation provides some code that comes from the client sdk.
This is a sample from the firebase documentation
import { getAuth, signInWithCredential, GoogleAuthProvider } from "firebase/auth";
// Build Firebase credential with the Google ID token.
const credential = GoogleAuthProvider.credential(id_token);
// Sign in with credential from the Google user.
const auth = getAuth();
signInWithCredential(auth, credential).catch((error) => {
// Handle Errors here.
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = GoogleAuthProvider.credentialFromError(error);
// ...
});
where the id_token (probably) comes from the request body.
This flow works just fine but it is using the client sdk in a nodejs server environment because the admin sdk that is inteded for such an environment does not support this kind of operation. So, is it ok to use both SDKs, where it is needed of course, in a nodejs server?
EDIT:
What I am trying to achieve is that when the google id_token (or facebook access token) arrives in my nodejs server I need to have a way to create an account in firebase auth module with the respective provider. So with the signInWithCredential if the user does not exist then will be created and then I will issue a custom token just like I do with the email/password strategy. The only difference here is that with email/password strategy I can use the admin SDK's createUser() for the user creation.
Is this approach right?
Your approach is absolutely right :
1- You recieve google ID token from client (OAuth or etc...)
2- Sign in user to firebase using google ID:
//1 import firebase/auth
import { getAuth, signInWithCredential, GoogleAuthProvider } from "firebase/auth";
//2 configue user credentials
const credential = GoogleAuthProvider.credential(id_token);
//3 run signInWithCredential function
let userData = await signInWithCredential(auth, credential)

Google Smartlock/Googleyolo did not return saved password

According to the documentation (https://developers.google.com/identity/one-tap/web/retrieve-credentials), we can get our saved password, just like when we use Credential Management API on Chrome.
I'm already currently logged in to Google in my browser.
I have tried to use the googleyolo api, using .retrieve() function as documented:
const retrievePromise = googleyolo.retrieve({
supportedAuthMethods: [
"https://accounts.google.com",
"googleyolo://id-and-password"
],
supportedIdTokenProviders: [
{
uri: "https://accounts.google.com",
clientId: "*********-**********.apps.googleusercontent.com"
}
]
}).then(res => console.log(res));
and it only return the idToken, no password returned.
But weirdly, when I tried using Credential Management API on Chrome my saved credentials popped up.
The question is,
1. What went wrong?
2. Where did googleyolo get its list of credentials? Because I checked at my https://passwords.google.com, and my credentials exists
3. What should I do/troubleshoot to get my password credentials?
Sorry for the confusion, passwords are only available in browsers that support the Credential Management API (which the library uses to retrieve the passwords). Will update the documentation to clarify that.
Not sure where you get the "googleyolo://id-and-password" from in the supportedAuthMethods argument. In your link, it specifically says only Google is supported.
googleyolo gets a list of users from your current browser. You will get more users if you have multiple users logged into a Google account.
When I implemented Google signon, I simply use the idtoken to confirm the identify of the user. No password is return from calling googleyolo.
Once you confirmed the user's identify, you can use the method provided to signin.
useGoogleIdTokenForAuth(credential.idToken);

Categories

Resources