1.0.3 • Published 2 years ago
firebase-auth-tokengen v1.0.3
firebase-auth-tokengen
日本語版はこちら → README-JA.md
Getting Started
$ npm install firebase-auth-tokengen
Preparation
Convert array firebaseConfig
generated by adding an app to a JSON file.
const fs = require('fs');
const firebaseConfig = {
apiKey: 'example',
authDomain: 'example.firebaseapp.com',
projectId: 'example',
storageBucket: 'example.appspot.com',
messagingSenderId: 'example',
appId: 'example',
};
fs.writeFile('credential.json', JSON.stringify(firebaseConfig), (err) => {});
How to use
from CUI
Show help:
firebaseauth-tokengen --help
Basic:
firebaseauth-tokengen --email test@example.com --password qwertyuiop --credential ./credential.json
Short input is also possible:
firebaseauth-tokengen -e test@example.com -p qwertyuiop -c ./credential.json
from script
import { getFirebaseAuthToken } from 'firebaseauth-tokengen';
let credential_path = 'YOUR_CREDENTIAL_PATH';
let email = 'example@example.com';
let password = 'P@ssw0rd';
getFirebaseAuthToken(credential_path, email, password)
.then((token) => console.log(token))
.catch((error) => console.error(error));
E-mail, Password, and JSON file path of credential are required options.