0

I want to use both Firebase Auth and Firebase Admin dependency in my project. So i have added below dependency

implementation 'com.google.firebase:firebase-auth:19.2.0'
implementation 'com.google.firebase:firebase-admin:6.12.2'

But i can't use below method from firebase auth

FirebaseAuth.getInstance().getCurrentUser();
FirebaseAuth.getInstance().signOut();

I can only have methods of FirebaseAuth from firebase-admin dependency. Some available methods are:

FirebaseAuth.getInstance().getUser(uid);
FirebaseAuth.getInstance().deleteUser(uid);

If i remove firebase-admin dependency I can use getCurrentUser, signOut and other methods from firebase-auth

Its like both dependency have same package FirebaseAuth class with different implementation. With some search i found that firebase-admin is for server side.

Is that means i can't use firebase-admin and firebase-auth in same project?

How can is use both in my project?

Give me some suggestion for this situation.

Thanks in advance.

Abu Yousuf
  • 5,729
  • 3
  • 31
  • 50
  • See https://stackoverflow.com/a/58494276 (by the author of the SDK), https://stackoverflow.com/q/42097740, https://stackoverflow.com/q/47581505, https://stackoverflow.com/q/59599189, https://stackoverflow.com/q/59079720 and more from https://www.google.com/search?q=site:stackoverflow.com+use+firebase+admin+in+android+app – Frank van Puffelen Feb 28 '20 at 22:10

1 Answers1

1

The Firebase Admin SDK is not intended for use in Android apps. It's for backend code running in a controlled server or desktop that you fully control. Please don't try work around this - instead your Android app should be invoking a backend that uses the Admin SDK to perform the work you need. It would be a fairly massive security hole for an app to have the Admin SDK and a service account bundled into it, as that leaves your project open to direct, easy abuse by anyone who can download your app and get the service account credentials.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441