-
Notifications
You must be signed in to change notification settings - Fork 4
/
client.go
53 lines (44 loc) · 1.19 KB
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package auth
import (
"errors"
"net/http"
"github.com/supabase-community/auth-go/endpoints"
)
var (
ErrInvalidProjectReference = errors.New("cannot create auth client: invalid project reference")
)
var _ Client = &client{}
type client struct {
*endpoints.Client
}
// Set up a new Auth client.
//
// projectReference: The project reference is the unique identifier for your
// Supabase project. It can be found in the Supabase dashboard under project
// settings as Reference ID.
//
// apiKey: The API key is used to authenticate requests to the Auth server.
// This should be your anon key.
//
// This function does not validate your project reference. Requests will fail
// if you pass in an invalid project reference.
func New(projectReference string, apiKey string) Client {
return &client{
Client: endpoints.New(projectReference, apiKey),
}
}
func (c client) WithCustomAuthURL(url string) Client {
return &client{
Client: c.Client.WithCustomAuthURL(url),
}
}
func (c client) WithToken(token string) Client {
return &client{
Client: c.Client.WithToken(token),
}
}
func (c client) WithClient(httpClient http.Client) Client {
return &client{
Client: c.Client.WithClient(httpClient),
}
}