Debian Codegraph @

internal/oauth2/providers/google/main.go

raw
1 package google
2
3 import (
4 "context"
5 "fmt"
6 "net/http"
7
8 "github.com/jkroepke/openvpn-auth-oauth2/v2/internal/config"
9 "github.com/jkroepke/openvpn-auth-oauth2/v2/internal/oauth2/providers/generic"
10 )
11
12 const Name = "google"
13
14 type Provider struct {
15 *generic.Provider
16
17 httpClient *http.Client
18 }
19
20 // NewProvider instantiates the Google provider using the generic implementation
21 // as a base. It wires in the HTTP client for REST API calls.
22 func NewProvider(ctx context.Context, conf *config.Config, httpClient *http.Client) (*Provider, error) {
23 provider, err := generic.NewProvider(ctx, conf, httpClient)
24 if err != nil {
25 return nil, fmt.Errorf("error creating generic provider: %w", err)
26 }
27
28 return &Provider{
29 Provider: provider,
30 httpClient: httpClient,
31 }, nil
32 }
33
34 // GetName returns the provider name used in configuration and logging.
35 func (p Provider) GetName() string {
36 return Name
37 }