Documentation
¶
Index ¶
- Variables
- func IsTimeoutErr(err error) bool
- type Config
- func (c *Config) Do(ctx context.Context, req *http.Request, v interface{}) (*opsmngr.Response, error)
- func (c *Config) GetToken(ctx context.Context, deviceCode string) (*Token, *opsmngr.Response, error)
- func (c *Config) NewRequest(ctx context.Context, method, urlStr string, v url.Values) (*http.Request, error)
- func (c *Config) PollToken(ctx context.Context, code *DeviceCode) (*Token, *opsmngr.Response, error)
- func (c *Config) RefreshToken(ctx context.Context, token string) (*Token, *opsmngr.Response, error)
- func (c *Config) RegistrationConfig(ctx context.Context) (*RegistrationConfig, *opsmngr.Response, error)
- func (c *Config) RequestCode(ctx context.Context) (*DeviceCode, *opsmngr.Response, error)
- func (c *Config) RevokeToken(ctx context.Context, token, tokenTypeHint string) (*opsmngr.Response, error)
- type ConfigOpt
- type DeviceCode
- type RegistrationConfig
- type Token
- type TokenSource
Constants ¶
This section is empty.
Variables ¶
var ErrTimeout = errors.New("authentication timed out")
ErrTimeout is returned when polling the server for the granted token has timed out.
Functions ¶
func IsTimeoutErr ¶
IsTimeoutErr checks if the given error is for the case where the device flow has expired.
Types ¶
type Config ¶
type Config struct { ClientID string AuthURL *url.URL UserAgent string Scopes []string // contains filtered or unexported fields }
func NewConfigWithOptions ¶
func (*Config) GetToken ¶
func (c *Config) GetToken(ctx context.Context, deviceCode string) (*Token, *opsmngr.Response, error)
GetToken gets a device token.
func (*Config) NewRequest ¶
func (*Config) PollToken ¶
func (c *Config) PollToken(ctx context.Context, code *DeviceCode) (*Token, *opsmngr.Response, error)
PollToken polls the server until an access token is granted or denied.
func (*Config) RefreshToken ¶
RefreshToken takes a refresh token and gets a new access token.
func (*Config) RegistrationConfig ¶
func (c *Config) RegistrationConfig(ctx context.Context) (*RegistrationConfig, *opsmngr.Response, error)
RegistrationConfig retrieves the config used for registration.
func (*Config) RequestCode ¶
RequestCode initiates the authorization flow by requesting a code.
type ConfigOpt ¶
func SetAuthURL ¶
SetAuthURL is a config option for setting the base URL.
func SetClientID ¶
SetClientID is a config option for setting the ClientID.
func SetUserAgent ¶
SetUserAgent is a config option for setting the user agent.
func SetWithRaw ¶
func SetWithRaw() ConfigOpt
SetWithRaw is a client option for getting raw atlas server response within Response structure.
type DeviceCode ¶
type DeviceCode struct { UserCode string `json:"user_code"` //nolint:tagliatelle // UserCode is the code presented to users VerificationURI string `json:"verification_uri"` //nolint:tagliatelle // VerificationURI is the URI where users will need to confirm the code DeviceCode string `json:"device_code"` //nolint:tagliatelle // DeviceCode is the internal code to confirm the status of the flow ExpiresIn int `json:"expires_in"` //nolint:tagliatelle // ExpiresIn when the code will expire Interval int `json:"interval"` // Interval how often to verify the status of the code // contains filtered or unexported fields }
DeviceCode holds information about the authorization-in-progress.
type RegistrationConfig ¶
type RegistrationConfig struct {
RegistrationURL string `json:"registrationUrl"`
}
type Token ¶
type Token struct { AccessToken string `json:"access_token"` //nolint:tagliatelle // used as in the API RefreshToken string `json:"refresh_token"` //nolint:tagliatelle // used as in the API Scope string `json:"scope"` IDToken string `json:"id_token"` //nolint:tagliatelle // used as in the API TokenType string `json:"token_type"` //nolint:tagliatelle // used as in the API ExpiresIn int `json:"expires_in"` //nolint:tagliatelle // used as in the API Expiry time.Time }
func (*Token) SetAuthHeader ¶
type TokenSource ¶
type TokenSource interface { // Token returns a token or an error. // Token must be safe for concurrent use by multiple goroutines. // The returned Token must not be modified. Token() (*Token, error) }
A TokenSource is anything that can return a token.