From 80ca94381b48d5766c5bcf7897a804d6e2443a69 Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Tue, 2 Jun 2026 13:13:08 -0400 Subject: credentials struct --- lulu.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'lulu.go') diff --git a/lulu.go b/lulu.go index 69a8ede..9228e28 100644 --- a/lulu.go +++ b/lulu.go @@ -58,17 +58,23 @@ type Client struct { c *http.Client } -// NewClient returns a client that will use the given client-key and -// client-secret to connect to the API server. -func NewClient(ctx context.Context, key, secret string) (*Client, error) { +// Credentials contains the client-key and client-secret used to +// authenticate to the API. +type Credentials struct { + Key, Secret string +} + +// NewClient returns a client that will use the given credentials to +// connect to the API server. +func NewClient(ctx context.Context, creds Credentials) (*Client, error) { tokenUrl, err := url.JoinPath(ApiUrl, tokenPath) if err != nil { return nil, pkgErrf(err, "error creating client") } cfg := &clientcredentials.Config{ - ClientID: key, - ClientSecret: secret, + ClientID: creds.Key, + ClientSecret: creds.Secret, TokenURL: tokenUrl, } return &Client{ctx, cfg.Client(ctx)}, nil -- cgit v1.2.3