For email and password authentication, you can use Firebase Auth REST API to create/login a user with provided credentials.
For OAuth providers such as Google and Github, you can follow OAuth 2.0 Device Authorization Flow described in RFC 8628 and then call Firebase's 'sign in with OAuth credential' to create the user in Firebase Authentication. Here's the general flow for Google Auth:
- Request device and user code from the OAuth provider (e.g. Google)
- Open the returned link in a browser and ask user to enter the code shown (user may have to open the browser in any other device if current one cannot open a browser e.g. in VMs)
- Keep polling for access token till you get the token or any of the errors listed in RFC 8628 section 3.5.
- Create/SignIn the user with Firebase using sign in with OAuth credentials REST API using the
accessToken
returned in previous step.
The last API will return Firebase Authentication's idToken
and refreshToken
that you can use to further authentication users in your backend.
Checkout OAuth 2.0 for limited input device apps for more information.
Do I need to package the Admin SDK?
No, the Admin SDK must be used only on server side as it has privileged access to your Firebase resources like bypassing security rules.
How to do I protect my Firebase keys (do the need to be in the CLI app)?
The keys are meant to be public (like an identifier for your project). See Is it safe to expose Firebase apiKey to the public? for more information.