Documentation
¶
Overview ¶
Package eveauth provides a client for authorizing desktop applications using the EVE Online Single Sign-On (SSO) service.
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client for authorizing desktop applications with the EVE Online SSO service. It implements OAuth 2.0 with the PKCE protocol. A Client instance is re-usable.
func NewClient ¶
NewClient returns a valid client from a configuration. It will return an error if the provided configuration is invalid.
The callback URL is constructed from the configuration and might look like this: http://localhost:8000/callback
func (*Client) Authorize ¶
Authorize starts the authorization flow and returns a new token when successful.
At the beginning the SSO login page will be opened in the browser. On completion of the flow a landing page will be shown in the browser.
This function blocks and can be canceled through the context and will then return ErrAborted.
Only one instance of this function may run at the same time. Trying to run another instance will return ErrAlreadyRunning.
type Config ¶
type Config struct {
// The SSO client ID of the Eve Online app. This field is required.
ClientID string
// The port for the local webserver to run. This field is required.
Port int
// The local path for the OAuth2 callback.
// The default is "callback".
CallbackPath string
// The name of the application shown to the user on the completion page.
// Will show "This application" when not configured.
ApplicationName string
// The HTTP client to use for all requests. Uses http.DefaultClient by default.
HTTPClient *http.Client
// Customer logger instance. Uses slog by default.
Logger LeveledLogger
// A function to open an URL in the system's browser.
// The default will open an URL in the default browser of the current system.
OpenURL func(string) error
// When enabled will keep the SSO server running and not start the authorization flow.
// This feature is for testing purposes only.
IsDemoMode bool
// OAuth2 authorization endpoint
AuthorizeURL string
// OAuth2 token endpoint
TokenURL string
}
Config represents the configuration for a client.
type LeveledLogger ¶
type LeveledLogger interface {
Error(msg string, keysAndValues ...any)
Info(msg string, keysAndValues ...any)
Debug(msg string, keysAndValues ...any)
Warn(msg string, keysAndValues ...any)
}
LeveledLogger is an interface that can be implemented by any logger or a logger wrapper to provide leveled logging (e.g. slog) The methods accept a message string and a variadic number of key-value pairs.
type Token ¶
type Token struct {
AccessToken string `json:"access_token"`
CharacterID int32 `json:"character_id"`
CharacterName string `json:"character_name"`
ExpiresAt time.Time `json:"expires_at"`
RefreshToken string `json:"refresh_token"`
Scopes []string `json:"scopes"`
TokenType string `json:"token_type"`
}
Token represents an OAuth2 token for a character in Eve Online.