This repository has been archived by the owner on Mar 31, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 80
error "Unauthorized request." when change to new private key #91
Comments
There was my mistake I've solved this error. |
@AddzMDev what was the issue Im running into the same issue? |
In my case I just put wrong configuration. |
There are nothing special. To explain that with my code here func firebaseAuth(keyPath, fbDbURL string) (fb *firego.Firebase, err error) {
d, err := ioutil.ReadFile(keyPath)
if err != nil {
log.Println("Error : ", err.Error())
os.Exit(0)
}
conf, err := google.JWTConfigFromJSON(d, "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/firebase.database")
if err != nil {
log.Println("Error : ", err.Error())
os.Exit(0)
}
fb = firego.New(fbDbURL, conf.Client(oauth2.NoContext))
firego.TimeoutDuration = time.Hour * 2
if fb == nil {
err = errors.New("fails to initialize firebase")
log.Println("Error : ", err.Error())
}
return
}
func main() {
keyPath := "/path/to/your/production/key" // make sure this path is point to your production key path
url := "https://your_product_project.firebaseio.com/" // make sure this url is your production database
if auth, e := firebaseAuth(keyPath, url); e != nil {
os.Exit(0)
}
} My former mistake was I had change kyePath variable in main function to production key but url variable still point to development database then Unauthorized request. error occur |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Just don't know what happen I've use firego for firebase realtime database and everything work fine in development but on production, I've generate new service key and replace that key with the same file that I've use in development. Then to authenticate there are no problem but I've got "error" : "Unauthorized request." when try to read data from realtime databsae
any idea ?
The text was updated successfully, but these errors were encountered: