eveauth

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 21 Imported by: 2

README

eveauth

A Go library for authorizing desktop applications with the EVE Online SSO service.

GitHub Release CI/CD codecov GitHub License Go Reference

Description

eveauth is a Go library for authorizing desktop applications with the EVE Online Single Sign-On (SSO) service.

It's key features are:

  • Authorize desktop apps with the EVE Online SSO service
  • Renew obtained token
  • Cross-platform support (e.g. Windows, macOS, Linux)
  • Logging support
  • Configurable client

[!TIP] Platform compatibility is mainly determined by the feature for opening a URL in the browser. The default configuration uses github.com/toqueteos/webbrowser, which provides this feature for many popular platforms including Windows, macOS and Linux. Other platforms can be supported by providing a platform specific implementation of this feature. For example the application EVE Buddy is using eveauth on Android with support from the Fyne GUI toolkit.

Installation

You can add eveauth to your Go module with the following command:

go get github.com/ErikKalkoken/eveauth

Usage

This section describes how to use the eveauth library.

Creating the SSO application

First you need to create an SSO application on the developers website.

Chose name and enabled scopes depending your requirements. Please make sure it as at least the pubicData scope for this example below to work.

Your callback URL should look something like this: http://localhost:8000/callback. The port (i.e. 8000) and callback path (i.e. callback) can be configured when creating the eveauth client.

The client ID generated for your SSO app will be needed later for configuring the eveauth client.

Using eveauth in a Go program

The following program shows how to use eveauth. It will open the system's default web browser and after completing the OAuth flow for a character will return a token with the publicData scope.

package main

import (
	"context"
	"fmt"

	"github.com/ErikKalkoken/eveauth"
)


func main() {
	client, err := eveauth.NewClient(eveauth.Config{
		ClientID: "YOUR-SSO-CLIENT-ID",
		Port:     8000,
	})
	if err != nil {
		panic(err)
	}
	tok, err := client.Authorize(context.Background(), []string{"publicData"})
	if err != nil {
		panic(err)
	}
	fmt.Println(tok)
}

Additional examples can also be found in the /examples directory.

Projects using eveauth

The following projects are using eveauth:

  • elt: A command line tool for looking up Eve Online objects.
  • EVE Buddy: A companion app for Eve Online players available on Windows, macOS, Linux and Android.

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

View Source
var (
	ErrAborted        = errors.New("process aborted prematurely")
	ErrAlreadyRunning = errors.New("another instance is already running")
	ErrInvalid        = errors.New("invalid operation")
	ErrNotInitialized = errors.New("not initialized")
	ErrTokenError     = errors.New("token error")
)

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

func NewClient(config Config) (*Client, error)

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

func (s *Client) Authorize(ctx context.Context, scopes []string) (*Token, error)

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.

func (*Client) RefreshToken

func (s *Client) RefreshToken(ctx context.Context, token *Token) error

RefreshToken refreshes token when successful or returns an error when the refresh has failed.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL