Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ruel/firebase-token-erlang
Custom Firebase token generator library for Erlang
https://github.com/ruel/firebase-token-erlang
custom-firebase-token erlang firebase firebase-token otp
Last synced: 4 days ago
JSON representation
Custom Firebase token generator library for Erlang
- Host: GitHub
- URL: https://github.com/ruel/firebase-token-erlang
- Owner: ruel
- License: mit
- Created: 2016-10-01T16:16:05.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-04T17:48:29.000Z (over 7 years ago)
- Last Synced: 2024-10-27T19:50:53.072Z (19 days ago)
- Topics: custom-firebase-token, erlang, firebase, firebase-token, otp
- Language: Erlang
- Size: 17.6 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Firebase Token Generator - Erlang
[![Build Status](https://travis-ci.org/ruel/firebase-token-erlang.svg?branch=master)](https://travis-ci.org/ruel/firebase-token-erlang) [![Hex.pm](https://img.shields.io/hexpm/v/firebase_token.svg)](https://hex.pm/packages/firebase_token)
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 https://firebase.google.com/docs/auth/server/create-custom-tokens for more information.
## OTP Version
**Required**: OTP 18 and later
## Setup
This can be added as a dependency from [hex.pm](https://hex.pm/packages/firebase_token)
```erlang
{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](https://console.developers.google.com/apis/credentials)
```erlang
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**.