Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why I get UNAUTHORIZED_DOMAIN:Domain not whitelisted by project?

Im trying to do the email authentication of firebase. I'm following the document and i get this error:

UNAUTHORIZED_DOMAIN:Domain not whitelisted by project

I saw this soultion: Firebase Auth/unauthorized domain. Domain is not authorized

and it didn't work, so I went and tried to create a dynamic link because I saw here that I need to create dynamic link: Firebase says "Domain not whitelisted" for a link that is whitelisted

and that also didn't work. i got when tried to create dynamic link:

An error occurred when creating a new Dynamic Link

so i went and tried this: Firebase console create dynamic link error

and still the same problem

so now I don't know what else to do.

the code:

 private void sendEmail(String email) {
        Log.d(TAG, "sendEmail: here in sendEmail");
        String url = "https://.........";
        ActionCodeSettings actionCodeSettings = ActionCodeSettings.newBuilder().setUrl(url)
                .setHandleCodeInApp(true)
                .setAndroidPackageName("com.myapp_pack.my_app_name", true, "12").build();


    auth.sendSignInLinkToEmail(email, actionCodeSettings).addOnCompleteListener(new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {
            if (task.isSuccessful()) {
                Log.d(TAG, "onComplete: email sent homie!");
            } else{
                Log.d(TAG, "onComplete: task failed " + task.getException().getMessage());
            }
        }
    });
}
like image 728
NoobProgrammer Avatar asked Nov 16 '22 17:11

NoobProgrammer


1 Answers

This was useful for me, using Firebase v.9 (current last version in January 2022)

Try not creating dynamic links but check if you are listing not just "localhost" (or where you would serve the project) but also the url you pass to the url property of the object you pass as the third parameter of "sendSignInLinkToEmail". Example:

const config = {
    url: "https://example.com/",
    *...other properties*
  };

  sendSignInLinkToEmail(auth, email, config).catch((error) => {
    console.log(error);
  });

In this case you would go to the firebase console and add in the whitelist "example.com".


Disclaimer: Checking this solved my problem as I was unintentionally only whitelisting the url where I was serving my project in dev mode.

like image 189
Lucas Serral Avatar answered Jan 20 '23 07:01

Lucas Serral