# Firebase Token Generator - Erlang 

[![Build Status](]( [![](](

Helper module for generating custom Firebase token in Erlang. Custom Firebase tokens are used on applications with totally different authentication methods. These tokens are in JWT (JSON Web Token) format and can be then used by client applications on authenticating to Firebase.

Only supports Firebase 3.x.x. See for more information.

## OTP Version

**Required**: OTP 18 and later

## Setup

This can be added as a dependency from [](

{deps, [
  {firebase_token, "1.1.0"}

## Usage

One of the requirements for this library is the service account key JSON file that can be obtained from the [Google API Manager Console](

Account = firebase_token_account:load_from_file("/path/to/service_account.json"),
%% Or you can load from binary string input
%% Account = firebase_token_account:load(<<"{ ...JSON String... }">>),

Uid = <<"1">>, %% Main user id string. Length must not exceed by 36
Life = 3600,   %% Token life (when to expire). Must not exceed 3600 seconds
Extra = #{     %% Arbitrary values
  admin => true

{token, _FirebaseToken} = firebase_token:generate(Account, Uid, Life, Extra).

> **NOTE**: Extras cannot have the following keys: **acr**, **amr**, **at_hash**, **aud**, **auth_time**, **azp**, **cnf**, **c_hash**, **exp**, **firebase**, **iat**, **iss**, **jti**, **nbf**, **nonce** and **sub**.