api

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 27 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

Types

type OAuthService added in v1.1.0

type OAuthService struct {
	// contains filtered or unexported fields
}

OAuthService obtains and maintains a bearer token via the OAuth flow. The zero value is not usable; construct one with NewOAuthService.

func NewOAuthService added in v1.1.0

func NewOAuthService() (*OAuthService, error)

NewOAuthService builds a service with the default issuer (overridable via the HOSTINGER_OAUTH_ISSUER env var) and the standard on-disk credentials path.

func (*OAuthService) Login added in v1.1.0

func (s *OAuthService) Login(ctx context.Context) (string, error)

Login runs the full interactive PKCE flow regardless of cache state.

func (*OAuthService) Logout added in v1.1.0

func (s *OAuthService) Logout(ctx context.Context) error

Logout best-effort revokes the access token and wipes local tokens, keeping the registered client_id so a later login can skip dynamic registration.

func (*OAuthService) Reauthenticate added in v1.1.0

func (s *OAuthService) Reauthenticate(ctx context.Context) (string, error)

Reauthenticate forces a fresh token, bypassing the cached-token fast path. It mirrors Token's refresh-then-login fallback and is meant for the reactive 401 recovery path, where the cached token is already known to be dead.

func (*OAuthService) Refresh added in v1.1.0

func (s *OAuthService) Refresh(ctx context.Context) (string, error)

Refresh exchanges the stored refresh token for a fresh access token.

func (*OAuthService) Token added in v1.1.0

func (s *OAuthService) Token(ctx context.Context) (string, error)

Token returns a usable access token: the cached one if still valid, otherwise a proactive refresh, otherwise a full interactive login.

Jump to

Keyboard shortcuts

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