MCPcopy Create free account
hub / github.com/openclaw/gogcli / newKeepWithServiceAccount

Function newKeepWithServiceAccount

internal/googleapi/keep.go:21–52  ·  view source on GitHub ↗
(
	ctx context.Context,
	serviceAccountPath string,
	impersonateEmail string,
	tokenSourceFactory ServiceAccountTokenSourceFunc,
)

Source from the content-addressed store, hash-verified

19}
20
21func newKeepWithServiceAccount(
22 ctx context.Context,
23 serviceAccountPath string,
24 impersonateEmail string,
25 tokenSourceFactory ServiceAccountTokenSourceFunc,
26) (*keep.Service, error) {
27 data, err := os.ReadFile(serviceAccountPath) //nolint:gosec // user-provided path (or stored config file)
28 if err != nil {
29 return nil, fmt.Errorf("read service account file: %w", err)
30 }
31
32 scopes, err := googleauth.Scopes(googleauth.ServiceKeep)
33 if err != nil {
34 return nil, fmt.Errorf("keep scopes: %w", err)
35 }
36
37 if tokenSourceFactory == nil {
38 return nil, errServiceAccountTokenSourceRequired
39 }
40
41 tokenSource, err := tokenSourceFactory(ctx, data, impersonateEmail, scopes)
42 if err != nil {
43 return nil, err
44 }
45
46 svc, err := keep.NewService(ctx, tokenSourceClientOptions(ctx, tokenSource)...)
47 if err != nil {
48 return nil, fmt.Errorf("create keep service: %w", err)
49 }
50
51 return svc, nil
52}

Calls 3

ScopesFunction · 0.92
tokenSourceClientOptionsFunction · 0.85
ErrorfMethod · 0.80