Firebase Auth Quickstarts

The Firebase Auth quickstart demonstrates several methods for signing in:

  • The Firebase email and password authentication quickstart demonstrates using a Firebase stored email & password to authenticate - you can both create and sign in a user.
  • The Firebase email link authentication quickstart demonstrates using an email address to sign-in without a password, via a link sent through email - you can both create and sign in a user.
  • The Firebase phone number authentication quickstart demonstrates using Firebase phone number authentication using three different techniques: with a visible ReCaptcha, an invisible ReCaptcha and a simplified popup flow (not recommended for production apps).
  • The Firebase Google Sign in quickstarts demonstrate using a Google account to authenticate to Firebase using three different techniques: with a popup, a redirect and an auth token.
  • The Firebase Facebook Login quickstarts demonstrate using a Facebook account to authenticate to Firebase using three different techniques: with a popup, a redirect and an auth token.
  • The Firebase Twitter Login quickstarts demonstrate using a Twitter account to authenticate to Firebase using two different techniques: with a popup and a redirect.
    • The Firebase Microsoft Login quickstarts demonstrate using a Microsoft account to authenticate to Firebase using two different techniques: with a popup and a redirect.
  • The Firebase GitHub Login quickstarts demonstrate using a GitHub account to authenticate to Firebase using two different techniques: with a popup and a redirect.
  • The Firebase Anonymous auth quickstart demonstrates how to authenticate to Firebase anonymously.
  • The Firebase custom auth quickstart demonstrates how to authenticate to Firebase with a user who has been authenticated from your own pre-existing authentication system. This is done by generating a token in a specific format, which is signed using the private key from a service account downloaded from the Google Developer Console. This token can then be passed to your client application which uses it to authenticate to Firebase. We provide an example token generator for demonstration purposes. Note: Generating tokens in production should be done server side.

We also provide the code for a Chrome Extension showing how to setup and authorize Firebase in a Chrome extension.

Getting Started

  1. Create a Firebase project on the Firebase Console.
  2. Add a support email to your project in the settings page. Some auth methods won't work without this.
  3. Enable the authentication method you want to use by going to the Authentication section in the SIGN-IN METHOD tab - you don't need to enable custom auth.
    • For Custom Auth, generate a Service Account credentials in your Firebase Console > Project Settings > Service Accounts, and click on GENERATE NEW PRIVATE KEYS. You will need it in the example token generator.
    • For Facebook, Twitter and GitHub you will need to create an application as a developer on their respective developer platform, whitelist https://<project_id>.firebaseapp.com/__/auth/handler for auth redirects and enable and setup the app's credentials in the Firebase Console > Authentication > SIGN-IN METHOD.
  4. You must have the Firebase CLI installed. If you don't have it install it with npm install -g firebase-tools and then configure it with firebase login.
  5. On the command line, cd into the quickstart-js/auth subdirectory.
  6. Run firebase use --add and select your Firebase project.

To run the sample app locally during development:

  1. Run firebase serve. This will start a server locally that serves auth/index.html on http://localhost:<port>. Check the output of the command for the exact port.
  2. Navigate in your browser to the URL output by the firebase serve command.

To deploy the sample app to production:

  1. Run firebase deploy. This will deploy the sample app to https://<project_id>.firebaseapp.com.

License

© Google, 2016. Licensed under an Apache-2 license.