attdona
attdona

Reputation: 18943

Authenticate with Firebase Using Email Link in Android: UNAUTHORIZED_DOMAIN error

From quickstart-android samples projects I'm trying the Firebase Auth Quickstart sample targeting the Passwordless method with these versions:

// Firebase Authentication
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.google.firebase:firebase-core:16.0.0'

// Google Sign In SDK (only required for Google Sign In)
implementation 'com.google.android.gms:play-services-auth:15.0.1'

// Firebase UI
// Used in FirebaseUIActivity.
implementation 'com.firebaseui:firebase-ui-auth:4.0.0'

I've followed the setup as documented in the project README but I get the following error (Logcat):

06-25 10:51:31.603 3657-3657/com.google.firebase.quickstart.auth W/PasswordlessSignIn: Could not send link
    com.google.firebase.FirebaseException: An internal error has occurred. [ UNAUTHORIZED_DOMAIN:Domain not whitelisted by project ]
        at com.google.firebase.auth.api.internal.zzce.zzb(Unknown Source:55)

The Firebase->Authentication->Authorized domain table contains <my-project-name>.firebaseapp.com as authorized domain.

What am I missing?

Upvotes: 3

Views: 3016

Answers (4)

Kairat
Kairat

Reputation: 788

Now you need to go Authentication->Settings->Authorized domains. And add the domain of your dynamic link. It must start with www, e.g: www.example.page.link

Upvotes: 2

  1. Copy domain from Dynamic Link:

enter image description here

  1. Go to Authentication in SignIn-Methods:

enter image description here

  1. Add your domain:

enter image description here

Upvotes: 2

Vũ Nguyễn Duy
Vũ Nguyễn Duy

Reputation: 93

For me, it works using this method:

ActionCodeSettings settings = ActionCodeSettings
  .newBuilder()
  .setUrl("https://auth.example.com/emailSignInLink")

Set Authorized domains in the console too: auth.example.com

Upvotes: 0

Paraskevas Ntsounos
Paraskevas Ntsounos

Reputation: 1777

enter image description here

First make sure that you already add domain 'yourdomain.com' to Authentication menu in Firebase at Authorized domains. If you already have your domain declared there, assuming that you are using:

compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
    minSdkVersion 16
    targetSdkVersion 27
}

Try to update to the latest version like:

    // Firebase Authentication
    implementation 'com.google.firebase:firebase-auth:16.0.2'
    implementation 'com.google.firebase:firebase-core:16.0.1'

// Google Sign In SDK (only required for Google Sign In)
    implementation 'com.google.android.gms:play-services-auth:15.0.1'

// Firebase UI
// Used in FirebaseUIActivity.
    implementation 'com.firebaseui:firebase-ui-auth:4.0.1'

Also make sure that you are using:

implementation "com.android.support:design:27.1.1"
implementation "com.android.support:customtabs:27.1.1"
implementation "com.android.support:cardview-v7:27.1.1"

Also if you are using other firebase libraries check that everything is updated based on this link:

    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.4'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-ads:15.0.1'
    implementation 'com.google.firebase:firebase-analytics:16.0.1'
    implementation 'com.google.firebase:firebase-appindexing:16.0.1'
    implementation 'com.google.firebase:firebase-auth:16.0.2'
    implementation 'com.google.firebase:firebase-firestore:17.0.1'
    implementation 'com.google.firebase:firebase-functions:16.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.0.0'
    implementation 'com.google.firebase:firebase-storage:16.0.1'
    implementation 'com.google.firebase:firebase-crash:16.0.1'
    implementation 'com.google.firebase:firebase-invites:16.0.0'
    implementation 'com.google.firebase:firebase-perf:16.0.0'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.firebase:firebase-config:16.0.0'

Upvotes: 1

Related Questions