Allows your Firebase users to authenticate in a CLI app.
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>.
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.
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)
}