Firebase is providing Admin SDK for golang, but some features are not supported yet.

https://firebase.google.com/docs/admin/setup

If you use unsupported services in golang, you must authenticate your services and create a client for it.

func NewService() (*AwesomeService, *Error) {
    // Pass service_account json file path here
    data, err := ioutil.ReadFile(service_account_JSON_path)
	if err != nil {
		log.Fatal(err)
    }

    // Service scope must be given.
    conf, err := google.JWTConfigFromJSON(data, __service_scope__)
	if err != nil {
		log.Fatal(err)
	}

    client := conf.Client(oauth2.NoContext)
    return awesomeService.New(client)
}

I am not sure if it’s the best. It’s more redundant than code using Admin SDK. Let me know if I am wrong, or feel free to create a PR to discussleave comments below.


discussion