Skip to content

nouney/firelogin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

firelogin

Allows your Firebase users to authenticate in a CLI app.

Demo

Install the demo:

$ go install github.com/nouney/firelogin/demo

Run it:

$ $GOPATH/bin/demo
Your browser has been opened to visit: http://localhost:8080

Authentication successfull. Welcome, <your full name>.

Getting started

Install firelogin:

$ go get github.com/nouney/firelogin

Copy/paste the code below then run it:

package main

import (
	"fmt"
	"log"

	"github.com/nouney/firelogin"
)

func main() {
	flogin := firelogin.New(&firelogin.Config{
		APIKey:      "<YOUR FIREBASE API KEY>",
		AuthDomain:  "<YOUR FIREBASE AUTH DOMAIN>",
	})
	// This will block until the user sign in
	user, err := flogin.Login()
	if err != nil {
		log.Panic(err)
	}
	fmt.Println("Authentication successfull! Welcome,", user.DisplayName)
}

It will open a FirebaseUI webpage allowing you to authenticate.

Customization

FirebaseUI

package main

import (
	"fmt"
	"log"

	"github.com/nouney/firelogin"
)

func main() {
    // no providers = all
	ui := firelogin.NewFirebaseUI(
		"AppName", 
		firelogin.GITHUB_AUTH_PROVIDER_ID, 
		firelogin.GOOGLE_AUTH_PROVIDER_ID
	)
	flogin := firelogin.New(&firelogin.Config{
		APIKey:      "<YOUR FIREBASE API KEY>",
		AuthDomain:  "<YOUR FIREBASE AUTH DOMAIN>",
		URL: "https://your-domain.com/yourpage",
	})
	user, err := flogin.Login()
	if err != nil {
		log.Panic(err)
	}
	fmt.Println("Authentication successfull! Welcome,", user.DisplayName)
}

Releases

No releases published

Packages

No packages published

Languages