forked from jason/cpolis
A bit of testing with firebase
This commit is contained in:
39
cmd/backend/firebase.go
Normal file
39
cmd/backend/firebase.go
Normal file
@ -0,0 +1,39 @@
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user