I am developing a website in Golang and need to authenticate each user so only they can read their own firebase user information.
I'm using Firebase V3 and the firego package for golang. I've tried using the fireauth package to authenticate a user with a generated token, but this package only supports Firebase V2.
How can I authenticate my users with Firebase 3 when they login through Steam's OAuth/OpenID on my website in Golang?
I've tried using the JWT package for Golang to generate a token then send it to the user to use firebase.auth().signInWithCustomToken(token)
to authenticate but I didn't manage to generate the token.
Here is the code I used to generate with JWT:
jwtToken := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
"uid": "172346362",
})
signKey, err := jwt.ParseRSAPrivateKeyFromPEM([]byte(`I don't know what to put here,
I tried a number of things including
randomly generated private RSA keys`))
if err != nil {
log.Fatal(err)
}
token, err := jwtToken.SignedString(signKey)
if err != nil {
log.Fatal(err)
}
tmpl, err := template.ParseFiles("index.html")
if err != nil {
log.Fatal(err)
}
if err := tmpl.Execute(w, token); err != nil {
log.Fatal(err)
}
I recieve the following error message when using this code:
Invalid Key: Key must be PEM encoded PKCS1 or PKCS8 private key