-
Notifications
You must be signed in to change notification settings - Fork 2
How to
Augusto Crespo edited this page Jul 8, 2021
·
4 revisions
The main goal of this document is to provide developer a tutorial of how to configure some parts of the site.
- A Firebase project created with Google sign-in method activated
- Firebase installed in the project
-
Create a firebase.js file
- Import Firebase and firebase auth module
- Create the const firebaseConfigu with all credentials required in your project: apiKey, authDomain, projectId, etc.
- Initialize firebase and create the var provider:
firebase.initializeApp(firebaseConfig); var provider = new firebase.auth.GoogleAuthProvider();
- Export firebase and provider
-
In Vue component
- Import the firebase.js file created before
- Create a method signInWithPopup calling the function:
.auth()
.signInWithPopup(provider)
.then((result) => {
this.credential = result.credential;
// This gives you a Google Access Token. You can use it to access the Google API.
this.token = this.credential.accessToken;
// The signed-in user info.
this.user = result.user;
})
.catch((error) => {
// Handle Errors here.
});
In order to create user roles such as "admin", Firebase does not support this directly, but it allows to set custom user claims. We managed this through backend. More info at: https://dev.to/emeka/securing-your-express-node-js-api-with-firebase-auth-4b5f
We managed this via backend
- A Node.js project with Express
- Octokit package
- Create a Github app to work as a middleware between the backend and the repository.
- Copy its App ID and Private key
- Install the app in the repository and copy its Installation ID.
- Import Octokit, and createAppAuth from @octokit/auth-app
- Create a const "installationOctokit" with the strategy createAppAuth and three params:
- App ID from the Github app
- Private key from the Github app
- Installation ID from the repository where it is installed the app
- Create an async await function to call Octokit to create the issue with the params you choose.
Example:
installationOctokit.request("POST /repos/*REPO-OWNER*/*REPO-NAME*/issues", {
owner: "*REPO-OWNER*",
repo: "*REPO-NAME*",
title: "",
body: ""
});
More info at:https://www.npmjs.com/package/octokit#authentication