FirebaseUI-Android icon indicating copy to clipboard operation
FirebaseUI-Android copied to clipboard

Unable to generate non-default short link for email authentication.

Open asfdfdfd opened this issue 4 years ago • 10 comments

I have several apps in one Firebase project. For each app I'm using separate short-url domain.

https://appname.page.link https://appnamedev.page.link https://appnamealt.page.link https://appnamealtdev.page.link etc

"appname" is the substitute of my real app name.

I'm using pretty standard code to authenticate

      val actionCodeSettings = ActionCodeSettings.newBuilder()
              .setUrl("https://www.google.com/")
              .setDynamicLinkDomain(BuildConfig.FIREBASE_DYNAMIC_LINKS_DOMAIN)
              .setHandleCodeInApp(true)
              .setIOSBundleId(BuildConfig.IOS_APP_BUNDLE)
              .setAndroidPackageName(requireContext().packageName, true, "699")
              .build()

      val providerEmail = AuthUI.IdpConfig.EmailBuilder()
              .enableEmailLinkSignIn()
              .setActionCodeSettings(actionCodeSettings)
              .build()

      val intent = firebaseAuthUI.createSignInIntentBuilder()
              .setAvailableProviders(listOf(providerEmail)).build()

      startActivityForResult(intent, REQUEST_CODE_FIREBASE)

I'm configuring FIREBASE_DYNAMIC_LINKS_DOMAIN via gradle and writing appropriate value here.

But every time in email with sign-in link i receive https://appname.page.link for any application. It's like setDynamicLinkDomain is not taken in account.

Also app name in email is always wrong. It sends "appname" instead of actual app name.

asfdfdfd avatar Jan 29 '20 16:01 asfdfdfd

@asfdfdfd thanks for reporting. First I need to figure out if this is a FirebaseUI issue or a general Firebase Auth on Android issue.

Does this happen to you if you try to use the Android SDK for email link sign in without FIrebaseUI? https://firebase.google.com/docs/auth/android/email-link-auth

samtstern avatar Jan 29 '20 16:01 samtstern

Hey @asfdfdfd. We need more information to resolve this issue but there hasn't been an update in 7 days. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Feb 06 '20 02:02 google-oss-bot

Ok, i've checked. When i've tried to use FirebaseAuth directly with the same ActionCodeSettings — everything was ok. I've received correct sign-in link on my email.

asfdfdfd avatar Feb 07 '20 16:02 asfdfdfd

@asfdfdfd thanks for checking! Sounds like this is definitely a bug in FirebaseUI then.

samtstern avatar Feb 07 '20 17:02 samtstern

please,When will version 6.2.1 be updated? Can version 6.2.1 solve this problem?

xiaopanwei avatar Mar 20 '20 08:03 xiaopanwei

@samtstern I looked into this issue because I was having the same problem and I think I found the problem

com.firebase.ui.auth.viewmodel.email.EmailLinkSendEmailHandler#addSessionInfoToActionCodeSettings is generating a new mutatedSettings that's finally used with firebase-auth in com.firebase.ui.auth.viewmodel.email.EmailLinkSendEmailHandler#sendSignInLinkToEmail

The problem is that these new "mutated" settings generated in addSessionInfoToActionCodeSettings are not preserving the custom domain that the user configured (here). The fix would be trivial but unfortunately ActionCodeSettings doesn't expose a getter for the DynamicLinkDomain. if it did, the fix would be a one-liner:

.setDynamicLinkDomain(actionCodeSettings.getDynamicLinkDomain())

I couldn't find a proper way to create an ActionCodeSettings with a different url but everything else equal. I wonder if that missing getter was just oversight or if it was on purpose (my guess is the first one). Is there anything you can do on your side?

theHilikus avatar Oct 07 '20 18:10 theHilikus

Actually, there is a getter, it is just that it's obfuscated. a slightly ugly and maybe unstable but trivial fix would then be

.setDynamicLinkDomain(actionCodeSettings.zze())

what do you think?

theHilikus avatar Oct 07 '20 18:10 theHilikus

@theHilikus thanks for digging into this! I'll see what I can do about the ActionCodeSettings visibility. We can't rely on .zze() unfortunately since that will change during each SDK release.

Edit: filed internal bug b/170376183 to track the visibiliy.

samtstern avatar Oct 08 '20 10:10 samtstern

I'm on 'com.firebaseui:firebase-ui-auth:8.0.2' facing the same issue. Any update?

zjamshidi avatar Aug 15 '23 09:08 zjamshidi

The fix could be as easy as creating a helper class shadowing the original Firebase ActionCodeSettings class.

zjamshidi avatar Aug 31 '23 05:08 zjamshidi