cpolis/cmd/backend/firebase.go

40 lines
645 B
Go
Raw Normal View History

2024-08-09 17:07:27 +02:00
package backend
import (
"context"
firebase "firebase.google.com/go/v4"
"firebase.google.com/go/v4/auth"
"google.golang.org/api/option"
)
type Client struct {
*auth.Client
}
func NewApp() (*Client, error) {
var err error
client := new(Client)
ctx := context.Background()
opt := option.WithCredentialsFile("path/to/serviceAccountKey.json")
app, err := firebase.NewApp(ctx, nil, opt)
if err != nil {
return nil, err
}
client.Client, err = app.Auth(ctx)
if err != nil {
return nil, err
}
return client, nil
}
func (c *Client) Verify(token string) (*auth.Token, error) {
ctx := context.Background()
return nil, nil
}