Firebase Cloud Function based OAuth2 GitHub backend for Netlify CMS
Switch branches/tags
Nothing to show
Clone or download
Herohtar Add prereq info to readme (#2)
* Added prerequisite section

* Added names of compatible Firebase plans

* Added link to Cloud Function docs
Latest commit e4dcfc4 Oct 24, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
functions Initial commit Sep 22, 2018
.gitignore Updated readme Sep 23, 2018 Add prereq info to readme (#2) Oct 24, 2018
firebase.json Initial commit Sep 22, 2018


This is a Firebase Cloud Function that allows Netlify CMS to authenticate with GitHub or GitLab via OAuth2.


0) Prerequisites

These instructions require that you have created a Firebase project and have installed and configured the Firebase CLI Tools. See the Firebase CLI Reference for more details.

1) Get the code

Clone the repository and install dependencies:

git clone
cd netlify-cms-oauth-firebase/functions
npm i

2) Create an OAuth app

You will need an OAuth app to authenticate with. For GitHub, the instructions can be found in the GitHub Developer Documentation.

For now, the values that you provide for the fields do not matter. The authorization callback URL will need to be configured once you have the Firebase Function URL in order for the service to work.

3) Configure the Firebase environment

Tell Firebase which project to use:

firebase use your-project-id

Set the oauth.client_id and oauth.client_secret Firebase environment variables using the values from the GitHub OAuth app:

firebase functions:config:set oauth.client_id=yourclientid oauth.client_secret=yourclientsecret

For GitHub Enterprise and GitLab you will need to set the oauth.git_hostname environment variable.

For GitLab you will also need to set the following additional environment variables as specified:


4) Deploy the function

Deploy the function to Firebase:

firebase deploy --only functions

At this point you should update the authorization callback URL in your GitHub OAuth app's settings to point to the URL of your Firebase function, which should be of the form:

5) Configure Netlify CMS

Finally, update your Netlify CMS config.yml to point to the function:

  name: github # Or gitlab
  repo: username/repo # Your username and repository
  branch: master # Branch to use
  base_url: # The base URL for your Firebase Function
  auth_endpoint: /oauth/auth # The path to the OAuth endpoint of the function


  • The OAuth2 API makes external network requests which requires a Firebase project that has billing enabled. (Spark or Blaze plan)
  • Firebase does not handle the function root correctly, so calls to (no trailing slash) will fail with the error "Cannot GET null". If for some reason you are trying to call the root function, you must use a trailing slash (