Quick code references:
- Setting-up 'firebase-admin' on the server (
server/src/rooms/MyRoom.ts
) - Providing Firebase's
accessToken
from client-side to the server-side (client/src/index.js
) - Verifying token provided by client on the server-side (
server/src/rooms/MyRoom.ts
) - Accessing authenticated user's data on the server-side (
server/src/rooms/MyRoom.ts
)
- Create a Firebase App
- Add "Anonymous" and "Email/Password" as Authentication providers on Firebase:
- Firebase Console > Authentication > Sign-in method > Anonymous > Enable
- Firebase Console > Authentication > Sign-in method > Email/Password > Enable
- Configure both client and server with the Firebase App credentials, as documented below
Replace the firebaseConfig
from client/src/firebase.js
with your Firebase app's credentials.
Starting the client:
npm install
npm start
(We are following the "Initialize the SDK in non-Google environments" documentation here.)
Add your service-account-file.json
file to the server/
folder.
You can get this file from the "Firebase Console" > "Project Settings" > "Service Accounts" > "Generate New Private Key".
Starting the server:
npm install
npm start