diff options
Diffstat (limited to 'lulu.go')
| -rw-r--r-- | lulu.go | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -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 |