{"id":19335040,"url":"https://github.com/acoshift/go-firebase-admin","last_synced_at":"2025-04-23T00:31:57.124Z","repository":{"id":57480666,"uuid":"77225319","full_name":"acoshift/go-firebase-admin","owner":"acoshift","description":"Unofficial Firebase Admin SDK for Golang","archived":false,"fork":false,"pushed_at":"2017-12-30T19:32:09.000Z","size":20130,"stargazers_count":59,"open_issues_count":7,"forks_count":21,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-06-18T21:40:27.272Z","etag":null,"topics":["firebase","firebase-admin","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/acoshift.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-23T12:52:54.000Z","updated_at":"2023-09-30T21:21:38.000Z","dependencies_parsed_at":"2022-09-26T16:31:05.780Z","dependency_job_id":null,"html_url":"https://github.com/acoshift/go-firebase-admin","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fgo-firebase-admin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fgo-firebase-admin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fgo-firebase-admin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fgo-firebase-admin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acoshift","download_url":"https://codeload.github.com/acoshift/go-firebase-admin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223906208,"owners_count":17223046,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["firebase","firebase-admin","golang"],"created_at":"2024-11-10T03:04:35.310Z","updated_at":"2024-11-10T03:04:35.842Z","avatar_url":"https://github.com/acoshift.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-firebase-admin\n\n[![Build Status](https://travis-ci.org/acoshift/go-firebase-admin.svg?branch=master)](https://travis-ci.org/acoshift/go-firebase-admin)\n[![Coverage Status](https://coveralls.io/repos/github/acoshift/go-firebase-admin/badge.svg?branch=master)](https://coveralls.io/github/acoshift/go-firebase-admin?branch=master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/acoshift/go-firebase-admin)](https://goreportcard.com/report/github.com/acoshift/go-firebase-admin)\n[![GoDoc](https://godoc.org/github.com/acoshift/go-firebase-admin?status.svg)](https://godoc.org/github.com/acoshift/go-firebase-admin)\n[![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php)\n\n## Table of Contents\n\n * [Overview](#overview)\n * [Installation](#installation)\n * [Features](#features)\n * [To-Do List](#to-do-list)\n * [Documentation](#documentation)\n * [Usage](#usage)\n   * [Authentication](#authentication)\n   * [Database](#database)\n   * [Messaging](#messaging)\n * [License](#license)\n\n## Overview\n\nFirebase Admin SDK for Golang\n\nOn Wednesday, May 17, 2017 [Google announced at Google IO][1] : Open sourcing the Firebase SDKs.\nBut for now, there is no official Admin SDK for Golang, only Java, Node and Python Admin SDKs.\n\nSo welcome go-firebase-admin SDK :)\n\n\u003e Note\n```\nIf you decide to use this unofficial SDK still in development,\nplease use any package manager to fix version, there will be a lot of breaking changes.\n```\n\n## Installation\n\nInstall the package with go:\n\n    go get github.com/acoshift/go-firebase-admin\n\n## Features\n\nThis go-firebase-admin SDK supports the following functions :\n\n- Authentication\n  * CreateCustomToken : [Generate JSON Web Tokens (JWTs) on your server][3], pass them back to a client device, and then use them to authenticate via the signInWithCustomToken() method.\n  * VerifyIDToken : [verify the integrity and authenticity of the ID token][4] and retrieve the uid from it.\n- User Management API\n  * GetUser : fetching the profile information of users by their uid\n  * GetUsers : fetching list of profile information of users by their uid\n  * GetUserByEmail : fetching the profile information of users by their email\n  * GetUsersByEmail : fetching list of profile information of users by their email\n  * GetUserByPhoneNumber : fetching the profile information of users by their phoneNumber\n  * GetUsersByPhoneNumber : fetching list of profile information of users by their phoneNumber\n  * ListUsers : fetching the profile information of users\n  * CreateUser : create a new Firebase Authentication user\n  * UpdateUser : modifying an existing Firebase user's data.\n  * DeleteUser : deleting existing Firebase user by uid\n  * SendPasswordResetEmail : send password reset for the given user\n  * VerifyPassword : verifies given email and password\n\n- Realtime Database API\n  * not documented\n\n- Cloud Messaging API\n  * SendToDevice : Send Message to individual device\n  * SendToDevices : Send multicast Message to a list of devices\n  * SendToDeviceGroup : Send Message to a device group\n  * SendToTopic : Send Message to a topic\n  * SendToCondition : Send a message to devices subscribed to the combination of topics\n  * SubscribeDeviceToTopic : subscribe a device to a topic\n  * SubscribeDevicesToTopic : subscribe devices to a topic\n  * UnSubscribeDeviceFromTopic : Unsubscribe a device to a topic\n  * UnSubscribeDevicesFromTopic : Unsubscribe devices to a topic\n\n## To-Do List\n\n- [ ] update documentation\n- [ ] add examples\n- [ ] add tests\n\n## Documentation\n\nYou can find more details about go-firebase-admin on [godoc.org][2].\n\n* [Firebase Setup Guide](https://firebase.google.com/docs/admin/setup/)\n* [Firebase Database Guide](https://firebase.google.com/docs/database/admin/start/)\n* [Firebase Authentication Guide](https://firebase.google.com/docs/auth/admin/)\n* [Firebase Cloud Messaging Guide](https://firebase.google.com/docs/cloud-messaging/admin/)\n* [Firebase Cloud Messaging Server](https://firebase.google.com/docs/cloud-messaging/server)\n* [Firebase Release Notes](https://firebase.google.com/support/releases)\n\n\n## Usage\n\nYou need a *service_account.json* file, if you don't have an admin SDK service_account.json, please [check this guide](https://firebase.google.com/docs/admin/setup#add_firebase_to_your_app)\n\nYou need a Firebase API Key for FCM, whose value is available in the [Cloud Messaging tab of the Firebase console Settings panel](https://console.firebase.google.com/project/_/settings/cloudmessaging)\n\nInitialize Firebase Admin SDK\n\n```go\npackage main\n\nimport (\n  \"io/ioutil\"\n\n  \"google.golang.org/api/option\"\n  \"github.com/acoshift/go-firebase-admin\"\n)\n\nfunc main() {\n  // Init App with service_account\n  firApp, err := firebase.InitializeApp(context.Background(), firebase.AppOptions{\n    ProjectID:      \"YOUR_PROJECT_ID\",\n  }, option.WithCredentialsFile(\"service_account.json\"))\n\n  if err != nil {\n    panic(err)\n  }\n\n}\n```\n### Authentication\n\n```go\npackage main\n\nimport (\n  \"io/ioutil\"\n\n  \"google.golang.org/api/option\"\n  \"github.com/acoshift/go-firebase-admin\"\n)\n\nfunc main() {\n  // Init App with service_account\n  firApp, err := firebase.InitializeApp(context.Background(), firebase.AppOptions{\n    ProjectID:      \"YOUR_PROJECT_ID\",\n  }, option.WithCredentialsFile(\"service_account.json\"))\n\n  if err != nil {\n    panic(err)\n  }\n\n  // Firebase AUth\n  firAuth := firApp.Auth()\n\n  // VerifyIDToken\n  claims, err := firAuth.VerifyIDToken(\"My token\")\n\n  // CreateCustomToken\n  myClaims := make(map[string]string)\n  myClaims[\"name\"] = \"go-firebase-admin\"\n  myClaims[\"ID\"] = \"go-go-go\"\n\n  cutomToken, err := firAuth.CreateCustomToken(claims.UserID, myClaims)\n\n}\n```\n\n### Database\n\n```go\npackage main\n\nimport (\n  \"io/ioutil\"\n\n  \"google.golang.org/api/option\"\n  \"github.com/acoshift/go-firebase-admin\"\n)\n\nfunc main() {\n  // Init App with service_account\n  firApp, err := firebase.InitializeApp(context.Background(), firebase.AppOptions{\n    ProjectID:      \"YOUR_PROJECT_ID\",\n    DatabaseURL:    \"YOUR_DATABASE_URL\",\n  }, option.WithCredentialsFile(\"service_account.json\"))\n\n  if err != nil {\n    panic(err)\n  }\n\n  // Firebase Database\n  firDatabase := firApp.Database()\n\n  type dinosaurs struct {\n    Appeared int64   `json:\"appeared\"`\n    Height   float32 `json:\"height\"`\n    Length   float32 `json:\"length\"`\n    Order    string  `json:\"order\"`\n    Vanished int64   `json:\"vanished\"`\n    Weight   int     `json:\"weight\"`\n  }\n\n  r := firDatabase.Ref(\"test/path\")\n  err = r.Child(\"bruhathkayosaurus\").Set(\u0026dinosaurs{-70000000, 25, 44, \"saurischia\", -70000000, 135000})\n  if err != nil {\n    panic(err)\n  }\n\n  // Remove\n  err = r.Remove()\n  if err != nil {\n    panic(err)\n  }\n\n  // Snapshot\n  snapshot, err := r.OrderByChild(\"height\").EqualTo(0.6).OnceValue()\n  if err != nil {\n    panic(err)\n  }\n\n}\n```\n\n### Messaging\n\n```go\npackage main\n\nimport (\n  \"io/ioutil\"\n\n  \"google.golang.org/api/option\"\n  \"github.com/acoshift/go-firebase-admin\"\n)\n\nfunc main() {\n  // Init App with service_account\n  firApp, err := firebase.InitializeApp(context.Background(), firebase.AppOptions{\n    ProjectID:      \"YOUR_PROJECT_ID\",\n    DatabaseURL:    \"YOUR_DATABASE_URL\",\n    APIKey:         \"YOUR_API_KEY\",\n  }, option.WithCredentialsFile(\"service_account.json\"))\n\n  if err != nil {\n    panic(err)\n  }\n\n  // FCM\n  firFCM := firApp.FCM()\n\n  // SendToDevice\n  resp, err := firFCM.SendToDevice(context.Background(), \"mydevicetoken\",\n\t\tfirebase.Message{Notification: firebase.Notification{\n\t\t\tTitle: \"Hello go firebase admin\",\n\t\t\tBody:  \"My little Big Notification\",\n\t\t\tColor: \"#ffcc33\"},\n\t\t})\n\n  if err != nil {\n    panic(err)\n  }\n\n  // SendToDevices\n  resp, err := firFCM.SendToDevices(context.Background(), []string{\"mydevicetoken\"},\n\t\tfirebase.Message{Notification: firebase.Notification{\n\t\t\tTitle: \"Hello go firebase admin\",\n\t\t\tBody:  \"My little Big Notification\",\n\t\t\tColor: \"#ffcc33\"},\n\t\t})\n\n  if err != nil {\n    panic(err)\n  }\n\n  // SubscribeDeviceToTopic\n  resp, err := firFCM.SubscribeDeviceToTopic(context.Background(), \"mydevicetoken\", \"/topics/gofirebaseadmin\")\n  // it's possible to ommit the \"/topics/\" prefix\n  resp, err := firFCM.SubscribeDeviceToTopic(context.Background(), \"mydevicetoken\", \"gofirebaseadmin\")\n\n  if err != nil {\n    panic(err)\n  }\n\n  // UnSubscribeDeviceFromTopic\n  resp, err := firFCM.UnSubscribeDeviceFromTopic(context.Background(), \"mydevicetoken\", \"/topics/gofirebaseadmin\")\n  // it's possible to ommit the \"/topics/\" prefix\n  resp, err := firFCM.UnSubscribeDeviceFromTopic(context.Background(), \"mydevicetoken\", \"gofirebaseadmin\")\n\n  if err2 != nil {\n    panic(err)\n  }\n\n}\n```\n\n## Licence\n\nMIT License\n\nCopyright (c) 2016 Thanatat Tamtan\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n[1]: https://opensource.googleblog.com/2017/05/open-sourcing-firebase-sdks.html\n[2]: https://godoc.org/github.com/acoshift/go-firebase-admin\n[3]: https://firebase.google.com/docs/auth/admin/create-custom-tokens\n[4]: https://firebase.google.com/docs/auth/admin/verify-id-tokens\n[5]: https://firebase.google.com/docs/auth/admin/manage-users\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facoshift%2Fgo-firebase-admin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facoshift%2Fgo-firebase-admin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facoshift%2Fgo-firebase-admin/lists"}