forked from cloudfoundry/cli
/
client.go
38 lines (31 loc) · 893 Bytes
/
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
package uaa
import "code.cloudfoundry.org/cli/api/uaa/internal"
//go:generate counterfeiter . AuthenticationStore
// AuthenticationStore represents the storage and configuration for the UAA
// client
type AuthenticationStore interface {
ClientID() string
ClientSecret() string
SkipSSLValidation() bool
AccessToken() string
RefreshToken() string
SetAccessToken(token string)
}
// Client is the UAA client
type Client struct {
store AuthenticationStore
URL string
connection Connection
}
// NewClient returns a new UAA client
func NewClient(URL string, store AuthenticationStore) *Client {
return &Client{
store: store,
URL: URL,
connection: NewConnection(URL, internal.Routes, store.SkipSSLValidation()),
}
}
// AccessToken returns the implicit grant access token
func (client *Client) AccessToken() string {
return client.store.AccessToken()
}