How to add Admin SDK api to android project - android

I am currently working in an Android application that requires to have Admin and regular users. To illustrate, the admin has the ability to manage the regular users like delete , modify their contents. According to my reserch that firebase provide Admin SDK API that can be realy sutiable for this issue but according to thier documention that Admin SDK cannot be used in the Android project itself and should be placed in the server-side of the project. In addition, i was tried to add the Admin SDK debendence to my project dependences but there is conflict between the libraries . I know what i was did is wrong to add the Admin SDK to the Bulid.gradle (app) but i did not manage to figure out how i can add the Admin SDK to my project.

What you've found is correct. Your case seems to be suitable for using Firebase Admin SDK.
Firebase Admin SDK needs a server app, on which it will be initialized.
Here you can find a full list of the prerequisites for setting-up Firebase Android SDK.
You can set-up Firebase Functions, which will hold your server-side code. Inside those functions you can also initialize the Firebase Admin SDK.
Please refer here for more information on Firebase Functions.
Here you can find a sample Firebase application which uses the Admin SDK. The sample shows how to authenticate access to a JSON API to only allow access to data for a specific Firebase user.
Firebase Functions are built to serve as serverless code, as you develop your server-side logic, then deploy it to a managed environment on Google's cloud. Those functions can contain all the logic that you would like to have using Admin SDK.

Related

How do I implement Admin SDK in my flutter so that I should Manage the users from Admin Panel?

I'm new to flutter working on my Final Year Project. I want to implement Admin functionalities in my App. So far I had implemented the data flow and the authentication things but I am stuck at implementing the Admin SDK for the removal of users from the auth table so that the admin has the complete priviligies.
Is there any alternate way possible? Or I have to implement the Admin SDK for this. Kindly guide? And if yes how should I do so?
The Firebase Admin SDKs are designed to be used in a trusted environment, such as your development machine, a server that you control, or Cloud Functions/Cloud Run. They are explicitly not to be used in client-side applications, like your Flutter app.
If you want to create a Flutter app that can be used to manage users, you'll want to:
Create your own API end points (e.g. with Cloud Functions or Cloud Run) where you use the Admin SDK to implement the necessary use-cases.
Secure those end points so that only authorized users can call them,
Then call the API end points from within your Flutter application code.
Also see:
How to use Firebase Admin SDK in Flutter?
is it possible to use firebase admin SDK in flutter web apps?
Flutter - Understanding Firebase Admin and how to get a user's information from email/uid/name

Connect Firebase Project under different project from another Google Cloud project

I currently have 2 firebase/google cloud projects. One for frontend and one for backend where app engine is hosted. I wanted to use firebase to send push notifications from the FCM token.
The code that I am using is the following:
Firebase.app = admin.initializeApp();
What this does is that it uses my backends firebase project not the firebase project of my frontend.
To connect to a different project's firebase I will have to do the following to my knowledge:
Firebase.app = admin.initializeApp({
credential: admin.credential.applicationDefault(),
});
And I will need to have an environment variable named GOOGLE_APPLICATION_CREDENTIALS
which will have to point to a google-credentials.json file containing the JSON object with the google credentials of the different applications.
I don't upload my google credentials json file as I am using cloud build from my Github.
I was trying the following approach:
Create a Base64 string of the json object and store it in a variable and then create a json file from the decoded base64 string and then point to the GOOGLE_APPLICATION_CREDENTIALS to the created file. But the google app engine does not allow for writing to files, so this is a dead-end unless there is something that will allow me to write to a file.
Is there some way I can link the firebase project of the frontend to the google cloud project of my backend so that the google cloud project directly links up the frontend's firebase project. If not then is there a way in which I can migrate the firebase project easily from the frontend firebase project to the backend firebase project?
Any suggestion would be a great help. Thanks!
There is no direct way to migrate the Firebase Application from one project to another project. You can refer to this stackoverflow thread to find this.
Also there is no way to migrate an App Engine application from one project to another. Instead you have to deploy the App Engine application in the new project.
So your concern narrows down to the fact that which one will be easier for you. I would suggest deploying the App Engine application in the same project where your Firebase frontend is already present. Because it seems easier as you only have to change the default project configuration in your SDK or Command Line Interface and follow this documentation.

How to add firebase custom claims without admin SDK?

I am developing a Android app with firebase as backend. I heard about firebase admin SDK but I don't know how to create it. I am using firebase console in web interface.
Now how can I set customer claims for a user?
You cannot. You could add custom claims from your local computer instead of Cloud functions or run a node process locally if you just need to add claims for a few users but the Admin SDK is necessary.
Checkout Firebase Custom Claims without Cloud Functions for detailed explanation on setting up admin sdk locally. You could just locally run functions or a node process to add claims as mentioned in there.

How to add Firebase Admin SDK to a Google Cloud Platform and communicate with an app?

I've been making an Android application which requires some users to have administrative controls when logged in. I have researched into how this is possible and can see that it requires the use of Firebase Admin SDK running on a server. Now the problem i am having is how can i actually set this up to communicate with my application?
This is the first time i have tried making an android application and used servers. I have read the documentation but this still hasn't made it clear to me of the components i need and how to piece them together. So far i have prepared...
Android Application (Developed in Java using Android Studio)
Google Cloud Platform (Server App to run admin SDK)
... but now i need to understand how i can run the admin SDK on my Google Cloud Function and use this for authorisation in my android app. Any advice or direction to helpful documentation would be hugely appreciated!
If you've never done something like this before, I'd recommend starting with callable Cloud Functions. The documentation has a nice example of how to implement these and call them from your Android code.
Inside the Cloud Function you can then use the Admin SDK to access for example Firebase Authentication. See the documentation importing the required modules for an example of how to set up the Admin SDK, and then the documentation of the Admin SDK for an example of how to get a list of users.

Same firebase project for both Android and iOS

My friend have finished setting up a Firebase backend for an Android application, and the project is on his private firebase account. Now I am starting to code the iOS version which should access the same Firebase backend.
My question is this... do I need to get his firebase email and password to work on the project or there​ is a way to import it to my account so I can work on it ?
tip: The solution should be like that, if any change happen in iOS or Android, must change in both of them.
You can add multiple developers to a single project, and you can have multiple apps added to your project. Do the following: your friend must add you to the project, and you must create an iOS application for that project in Firebase.

Categories

Resources